Here's a small howto on commenting and uncommenting multiple lines at once using vim.
Commenting multiple lines at once
-
Open your file in Vim:
vim your_file.txt
-
Go to Normal mode (press
Esc
a few times just to be sure) -
Enter Visual Line Mode:
-
Press
Shift + V
(capitalV
) -
Use
j
or arrow keys to select multiple lines
-
-
Run the substitute command:
-
Press
:
(you'll see something like:'<,'>
appear) -
Type:
s/^/# /
-
Then press
Enter
-
Uncommenting multiple lines at once
-
Open your file in Vim:
vim your_file.txt
-
Go to Normal mode (press
Esc
a few times just to be sure) -
Enter Visual Line Mode:
-
Press
Shift + V
(capitalV
) -
Use
j
or arrow keys to select multiple lines
-
-
Run the substitute command:
-
Press
:
(you'll see something like:'<,'>
appear) -
Type:
s/^# //
-
Then press
Enter
-
If this post was enjoyable or useful for you, please share it! If you have comments, questions, or feedback, you can email my personal email. To get new posts, subscribe use the RSS feed.