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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With