While analysing a long XML file I was inspired to play with folding in VIM. I set it up to enable folding for C, Python and XML. A middle mouse click will open a fold and a double click will close it. By default all folds are hidden. This does add a delay when the file is opened but once everything is folded it does make navigation easier. I must try to get into the habit of using this.
Here are the mappings:
" kinda like - to close folds, shift - to close all folds,
" + to open a fold and shift + to open all folds.
:map - zC
:map _ zM
:map = zO
:map + zR
:noremap <MiddleMouse> <LeftMouse>zO
:noremap <2-MiddleMouse> <LeftMouse>zC
The <LeftMouse> in the last two is there to move the caret to wherever the cursor is, otherwise the fold is opened or closed where the cursor is.
This goes in the ftplugin/c.vim file:
:syn region myFold start="{" end="}" transparent fold
:set foldmethod=syntax
:%foldo!
The last causes all folds to be open by default.
|