Skip to content

Instantly share code, notes, and snippets.

@sangdth
Last active November 5, 2020 08:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sangdth/98c75112306316fa0bba379d2dc07627 to your computer and use it in GitHub Desktop.
Save sangdth/98c75112306316fa0bba379d2dc07627 to your computer and use it in GitHub Desktop.
Setup folding for vim

Setting in your .vimrc:


" Fold by syntax because there are indent is not always correct
set foldmethod=syntax

" Beware, there are lot of instructions tell you use `set nofoldenable` to avoid folding at start
" but then when you start using `z c`, it will start the fold method and automatic fold ALL the code.
" Using this with `foldlevel` give the same effect but does not have that problem.
set foldenable

set foldlevel=20 " Bigger than 20 does not work

Using:

  • z c to fold.
  • z o to open it.

How to remember:

  • Imagine z is a folded paper :)
  • c is close. o is open.
  • Enjoy vim.

Read more: https://vim.fandom.com/wiki/Folding

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment