v -> select whatever needs to be commented out
(appears this) :'<,’>
(it will be now :'<,’>s/^/#)
For commenting out a block of text, do the following:
- hit CTRL + v (visual block mode)
- use the down arrow keys to select the lines you want (it won’t highlight everything)
- Shift + i (capital I)
- insert the caracter/text you want to add at the beginning of the line (e.g. #)
- Press ESC.
To uncomment a block:
- Go the to first line of code where you want to start uncommenting from.
- Press 0 (To bring the cursor to the beginning of the line.)
- CTRL + v and select lines to be uncommented.
- x that will delete all the # characters vertically.