Vim Tips Wiki
Advertisement

Duplicate tip

This tip is very similar to the following:

These tips need to be merged – see the merge guidelines.

Tip 1091 Printable Monobook Previous Next

created December 29, 2005 · complexity basic · author Anon · version 6.0


Sometimes you see too much code.

To organise the code clutter on your screen, you can temporarily hide blocks of code that are not currently of interest. This tip does not change your file; only the display changes.

1. Put this in your vimrc

:set foldmethod=manual
:map + v%zf

2. Now put your cursor on any brace of a block you want to hide (fold), and press the '+' key.

3. You can also view/unfold the hidden block by pressing Space inside the folded text.

4. To hide an arbitrary block, press:

v<move>zf

See also

Comments

One more tip for C coders, put this in vimrc and use Alt-a to open/close blocks of {code}:

:syn region myFold start="{" end="}" transparent fold
:syn sync fromstart
:set foldmethod=syntax
:map <A-a> za

And for comments:

:syn region Comment start="/\*" end="\*/" fold

Advertisement