Showing posts with label Vim. Show all posts
Showing posts with label Vim. Show all posts

Sunday, March 25, 2018

Multiple lines comment and uncommnet in VIM

To comment out blocks in vim:

  • press Esc (to leave editing or other mode)
  • hit ctrl+v (visual block mode)
  • use the up/down arrow keys to select lines you want (it won't highlight everything - it's OK!)
  • Shift+i (capital I)
  • insert the text you want, i.e. %
  • press EscEsc


To uncomment:

Put your cursor on the first # character, press CtrlV (or CtrlQ for gVim), and go down until the last commented line and press x, that will delete all the # characters vertically.

Duplicating a line in Vim Eiditor



yy or Y to copy the line 
or 
dd to delete (cutting) the line
then
p to paste the copied or deleted text after the current line 
or 
P to paste the copied or deleted text before the current line