Vim Recipes ‣ Navigation ‣ Navigating Folds
Your document contains folds and you want to use them for navigation. (To create folds see Manually Creating Folds).
| Command | Action | Mnemonic |
|---|---|---|
| zc | Close the current fold. | close fold |
| zo | Open the current fold. | open fold |
| zM | Close all folds. | fold More |
| zr | Open one level of folds. | reduce folding |
| zR | Open all folds. | Reduce folding |
| zj | Move to the next fold. | j moves to the next line |
| zk | Move to the previous fold. | k moves to the previous line |
| zm | Close one level of folds. | Fold more |
| zn | Disable folding. | no folds |
| zN | Re-enable folding. | N is n toggled |
You can use zM to achieve a birds-eye view of the file, which can be useful when you're writing a long book and forget how the recipe you're currently writing relates to…
Vim treats folds like individual lines, so j and k move over one fold at a time. Further, you can yank/deleteyank is Vim terminology for copying text to the clipboard; see Copying, Cutting, and Pasting. a fold as if it was a single line.
By default, folds are forgotten when you edit another file. To save them use :mkview. Then, to restore them, use :loadview.
The :set foldcolumn=W command, where W is a integer width less than 13, displays a column along the left-hand side of the screen with information about the folds in the current file. It indicates whether the corresponding line is an open or closed fold (with - or +, respectively).