In large codes, it is easier to navigate in folded code snippets. To fold we have several methods
-
To fold manually, just use
:set foldmethod=manual, and to fold a code snippet, just select the code in visual mode and presszf, to unfold you can usezoandl. To toggle back to folded view just usezaback and forth. -
Folds are not saved as you quit file, so before quitting you must ensure to use the editor command
:mkview, opening file once again after quitting , use:loadviewto see the folds. -
To delete all the folds just use
zD, to delete one fold usezd.
It is fastest way to fold the Indented content. To use this method , :set foldmethod=indent
Depending upon the cursor, it will automatically fold the indented blocs.