Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

confused by capital I in vim

Tags:

vim

vi

I follow these step whenever I want to comment a block of code:

1) Enter Blockwise Visual mode by hitting CTRL-V.
2) Mark the block you wish to comment.
3) Hit I (capital I) and enter your comment string at the beginning of the line. (// for C++)
4) Hit ESC and all lines selected will have 

However, I am not quite sure what I does there. And why ESC causes the insert on each line in the block.

like image 542
vehomzzz Avatar asked Dec 28 '10 20:12

vehomzzz


1 Answers

In block select mode I tells VIM to switch to insert mode with the cursor before the first character in the first line of the block.

All of the characters that you type on that first line will be inserted in front of all of the lines in the selection, right before the selected block.

You can do the same with A, except that you will add it after the block.

like image 187
Nathan Fellman Avatar answered Oct 16 '22 00:10

Nathan Fellman