Vim Folding
by Schmitty
…I rarely take sides in any of the ‘Geek Holy Wars’, however, I do make an exception for Vi. Vim is hands down the most beautiful editor I have ever used, and I am not afraid to say it. Imagine my surprise then when I discovered this feature!
“Using Vim’s folding features, you can tuck away portions of a file’s text so that they’re out of sight until you want to work with them again.”
Vim folding commands:
zf: creates a fold
zj: moves the cursor to the next fold.
zk: moves the cursor to the previous fold.
zo: opens a fold at the cursor.
zO: opens all folds at the cursor.
zm: increases the foldlevel by one.
zM: closes all open folds.
zr: decreases the foldlevel by one.
zR: decreases the foldlevel to zero -- all folds will be open.
zd: deletes the fold at the cursor.
zD: Delete folds recursively at the cursor.
zE: deletes all folds.
[z: move to start of open fold.
]z: move to end of open fold.
Also of interest:
set foldmethod=foldoption
au BufWinLeave * mkview
au BufWinEnter * silent loadview
