Detractors of Vim highlight its many native flaws - yet there is a unlimited supply of extensions for those who look. Code folding is a pretty handy tool for coding, especially for closing tags.

The default setting for code folding in Vim is manual, this means you will need to select the rows you want to collapse and use the key commands to fold and unfold the code.

1 Use V to select the code
2 :zf to fold it
3 :za to toggle it once your inside the block.

Vim also has auto folding by indent and other folding methods. You can also configure it to fold by using space or any other key you prefer.

For example: this one toggles the fold with space (instead of :za). You can add it to your .vimrc.

nnoremap <silent> <Space> @=(foldlevel('.')?'za':"\<Space>")<CR> vnoremap <Space> zf

For fuller information see the Vim Wikia