Your cart is currently empty!
Vim: Fold
Mode
:set foldmethod=normal :set fdm=normal
manual | Manually define fold range. |
indent | Automatic make the folds based on indent. |
syntax | Automatic make the folds based on your file extension. |
expr | Use :set foldexpr=TODO . |
marker | Manually define fold range and add a marker. |
diff | vim -d file1 file2 vimdiff file2 file2 :set diffopt=filler,context:0 |
Operator
zf {motion} | Define fold using motion. zfiB , zfib , zfi[ , zfj |
{count}zF | Define fold using count. 2zF = zfj = :.,+1fo = 2:fo |
:{range} fo | Define fold using range. :.,+1fo = 2zF = zfj |
zd | Delete fold at the cursor. |
zE | Delete all fold in the buffer. |
zo | Reveal fold at the cursor. |
zc | Close fold at the cursor. |
za | Toggle reveal/close at the cursor. |
zi | Turn fold on/off. |
zr | Unfold (reveal) per-level. |
zm | Fold (close) per-level. |
zR | Reveal all folds in the buffer. |
zM | Close all folds in the buffer. |
zO | Reveal all folds from cursor’s root. |
zC | Close folds from cursor’s child to its root. root |__childA |__childB When you press zC while your cursor at childA it will fold to root. When you reveal root, childA is folded, childB is not. |
zA | Toggle zO /zC . |
zk | Up one fold section. |
zj | Down one fold section. |
Saving a fold
In manual mode, when you close the buffer, the fold is gone.
To save the fold the memory, use :mkview
. To load from the memory, use :loadview
.
To save the fold to a file, use :mkview <filename>
. To load the fold from a file, use :loadview <filename>
.
Fold column
:set foldcolumn=0-9 :set fdc=0-9
References:
Leave a Reply