A feature which lets visually hide (and toggle) regions of a text file, by replacing its contents with a single outline line.

It is very useful to expand and collapse sections of a text file using folding, as it makes it easier to navigate around the document and to work on whole regions as they were single lines.

Folding is activated via the foldmethod (abbreviated to fdm) option, which is local to each of the and determines what kind of folding applies in the current window.

Possible values for foldmethod are:

  • manual – folds must be defined by entering commands (such as zf)
  • indent – groups of lines with the same indent form a fold
  • syntax – folds are defined by
  • expr – folds are defined by a user-defined expression

In addition, foldmethod may have values:

  • marker – special characters can be manually or automatically added to your text to flag the start and end of folds
  • diff – used to fold unchanged text when viewing differences (automatically set in mode)

For more information: Folding on vim.wikia

history | excerpt history