PLZZ LET ME KNOW HOW TO COMMENT MULTIPLE LINES IN A VI EDITOR???
PLZZ LET ME KNOW HOW TO COMMENT MULTIPLE LINES IN A VI EDITOR??? |
User loginRecent blog postsWho's onlineThere are currently 0 users and 19 guests online.
|
No need to count lines in regular vi
Instead of counting lines ( using: .,+N ) one could also use a search ( .,/WORDONTHELASTLINE/ ),
so
this is line 1
this is line 2
this is line three
this is line 4
could be commented by putting the cursor on line 1 and using:
.,/three/ s/^/#/g
Commenting multiple lines in VI editor...
To comment out multiple lines while writing scripts under vi where "#" is the comment marker.
Where "N" is number of lines to be commented after the current cursor location inclusive of the current line.
With vim
You can also use Visual Mode if you don't want to count lines :
Press [Esc] key
Use arrows to move cursor to the beginning of your paragraph
Press [v] to enter Visual Mode
Use arrows to select all the lines you want to comment
Then type the following command :
:'<,'>s/^/#/gNote : when you hit ':' in Visual Mode, ":'<,'>" is added automatically.
To remove comment, same procedure but :
:'<,'>s/^#//gPost new comment