Skip to content
Tags

,

Block operations in vim

March 25, 2011

To perform operations (insert text and may be do some other operations) in block mode follow the following steps:

1. Mark the area which is to be commented using the *blockwise* visual mode (CTRL-V, in Windows this is CTRL-Q).

2. Press I (capital i) and write the text you want to prepend to each line of the selected block, e.g. %.

3. Then press ESC and the text will be inserted to the left of each line of the selected block.

Now, in the steps above,  the above part ‘I’ only indicates that we want to add stuff at the beginnning of the line. you can substitute I for the following to do other operations:

i. <a> (append after cursor),

ii. <i> (insert before cursor),

iii.<A> (append at end of line),

iv.<I> (insert at beginning of line),

v. <C> (change to end of line), and

vi. <s> (substitute characters).

http://en.wikibooks.org/wiki/Learning_the_vi_editor/Vim/Modes#insert_.28and_replace.29

 

 

Advertisements

From → Uncategorized

Leave a Comment

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

%d bloggers like this: