On Friday 06 October 2006 08:24, Andy Wokula wrote: > Kamaraju Kusumanchi schrieb: > > I use two mappings for my Fortran (.f90) files > > > > map <F5> <Home>v%zf > > map <F6> <Home>zDv%zf > > > > The idea is to create folds for code blocks which are of the form > > > > subroutine some_name_here > > statements_here > > end subroutine some_name_here > > > > Here F5 folds the subroutine block irrespective of whether there are any > > folds within it. F6 folds the subroutine block after deleting the > > existing folds. > > > > However, if there are no folds and if I press F6, I get an error saying > > that > > > > E490: No fold found > > > > Is it possible to combine these two maps into a single map such that > > 1) If there are no existing folds, create a fold (i.e. perform <F5>) > > 2) If there are already some folds defined, then delete them and define a > > new fold (i.e. perform <F6>) > > > > Any ideas? > > > > thanks > > raju > > Some time ago I saw this: > http://vim.sourceforge.net/tips/tip.php?tip_id=1330 > > Andy
Thanks for the pointer. I tried nnoremap <F5> @=((foldclosed(line('.')) < 0) ? '<Home>v%zfjj' : '<Home>zDv%zfjj')<CR> but it did not work due to <Home>. Dont know how to escape it properly. Any ideas? For now I am using nnoremap <F5> @=((foldclosed(line('.')) < 0) ? '1\|v%zfjj' : '1\| zDv%zfjj')<CR> but would like to use <Home> instead of 1\| since that would make the map more readable. thanks raju -- http://groups.google.com/group/ask-anything/about