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 vim-windows and determines what kind of folding applies in the current window.
Possible values for
manual– folds must be defined by entering commands (such as
indent– groups of lines with the same indent form a fold
syntax– folds are defined by syntax-highlighting
expr– folds are defined by a user-defined expression
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 vimdiff mode)
For more information: Folding on vim.wikia