How to comment out multiple lines at once in vim
My name is Ito and I am an infrastructure engineer.
If you want to edit files on Linux, you probably use "Vim".
When editing a configuration file, you
may want to comment out multiple lines at once when commenting out unnecessary settings.
This time I would like to introduce the method.
Use rectangular selection mode
For operations on multiple lines, use "Short selection mode".
After opening the file with vim, enter the command below.
ctrl+v
Enter "Rectangle Visual Mode".
Select the line you want to comment out with your cursor.
I (shift + i)
"Insert mode".
Enter the character to comment out (such as "#")
Esc
Exit insert mode.
I summarized it in GIF.
What do you think?
The comment out character has been inserted at the beginning!
Let's do our best to master Vim.
If you found this article helpful , please give it a like!