If you are dealing with a long program file, it might be interesting to hide part(s) of it to make it more readable for instance. VIM provides these features : folding for hiding sections of text and unfolding forĀ  printing texts again.

Here are the basic VIM keyboard shortcuts to type in normal mode :

zfa} : create a fold within two brackets. the cursor is located after the opening bracket and the second one is indicated by }

zc : close the current fold

zo : open the current fold

zd : delete the fold at the cursor

[z : move to start of open fold

z] : move to end of open fold

You can create folders as many as you want within your current file. If you exit from your VIM editor, you will lose all of them.

For more details about folding/unfolding commands in VIM :

VIM folding