RSS

[vim] Fold lines in vim

14 Oct

These are the vim folding commands that “fold” certain lines in the file in order to help you focus at certain part of it:

zf#j creates a fold from the cursor down # lines.
zf/string creates a fold from the cursor to string .
zj moves the cursor to the next fold.
zk moves the cursor to the previous fold.
zo opens a fold at the cursor.
zO opens all folds at the cursor.
zm increases the foldlevel by one.
zM closes all open folds.
zr decreases the foldlevel by one.
zR decreases the foldlevel to zero — all folds will be open.
zd deletes the fold at the cursor.
zE deletes all folds.
[z move to start of open fold.
]z move to end of open fold.

Ex like range commands also work: e.g, “:10,20 fold” will fold lines 10 through 20.

You may use the following in your ~/.vimrc file to automatically fold lines when you indent them (for example in a program file):
set foldmethod=indent

Reference: Linux.com. You may also find the vim documentation for folds using “:help foldmethod” while you are looking at a file using vim.

About these ads
 
Leave a comment

Posted by on October 14, 2012 in linux, unix, vim

 

Tags: , , , ,

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

Join 31 other followers

%d bloggers like this: