Obsolete tip
This tip has been merged into another tip.
See VimTip108 for the current tip.
Please do not edit this tip, and do not edit the discussion page.
If anything needs to be improved, please fix VimTip108.
created June 2, 2005 · complexity basic · author brailsmt · version 6.0
This is a simple keymapping to make adding folds to source code simpler. I use foldmethod=marker, but that shouldn't be necesary for this tip. It will fold the current block (block being anything delimted with '{' and '}') no matter where you are in that block.
Add this to your vimrc:
nmap <silent> <Leader><Leader> [{V%zf
Comments
[{zf% is enough.
Can you explain what key to press and what will happen?
Seems like the tip is meant for people who already know what it is about?
In his mapping the "<Leader><Leader>" signifies the keys used to invoke the command.
<Leader> is a special variable for vim mappings, which represents a user configured key.
The <Leader> defaults to '\' (backslash), but can be changed to another key if you wish.
So, by default, to invoke the mapping above you would use '\\' (backslash backslash).
See :help mapleader.
I think "zfa}" is enough.
Well, it's not working on my computer which runs vim6.3.
Since the cursor must be under the '{' , i have to use a search:
nmap <silent> <Leader><Leader> /{<CR>zf%
It works, and it folds the block which is closest to your cursor.