Folding and unfolding with VIM

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


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.