top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

Is there any way to comment multiple lines together in vim editor ?

+2 votes
65 views
Is there any way to comment multiple lines together in vim editor ?
posted May 9, 2017 by Ganesh

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

0 votes

Yes, it is possible to delete or insert one character or set of characters before multiple lines by going to into visual mode (Ctrl+V)
Then selects multiple lines by doing up / down arrows. Once lines get selected then press "d" to delete the selected columns.

If you want to insert then press (Shift + i) then type character. After doing that press "Esc" so that character will be inserted in all the selected lines.

answer May 10, 2017 by Harshita
0 votes
  1. First, go to the first line you want to comment, press Ctrl+V. This will put the editor in the VISUAL BLOCK mode.
  2. Then using the arrow key and select until the last line
  3. Now press Shift+I, which will put the editor in INSERT mode and then press #. This will add a hash to the first line.
  4. Then press Esc (give it a second), and it will insert a # character on all other selected lines. Similarly we can achieve // or any other commenting option.
answer May 10, 2017 by Salil Agrawal
Similar Questions
–1 vote

I have a large file which has "some string"so many times, i want it to be replaced with "other string" at all places, using vi or vim editor?
Is there any way to do that?

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...