vi is a powerful text editor for Linux if you know most of its command line hacks. One common thing you might want to do is is commenting or uncommenting multiple lines using the terminal vi editor. In this tutorial I will explain the steps required for that.
Commenting Multiple Lines
Follow the steps given below for commenting multiple using the terminal.
- First, press
- Go to the line from which you want to start commenting. Then, press
ctrl + v, this will enable the visual block mode.
- use the
down arrowto select multiple lines that you want to comment.
- Now, press
SHIFT + Ito enable insert mode.
#and it will add a comment to the first line. Then press
ECSand wait for a second,
#will be added to all the lines.
You Might Like: Learn DevOps: The Complete Kubernetes Course
Uncommenting Multiple Lines
CTRL + Vto enable visual block mode.
- Move down and select the lines till you want to uncomment.
xand it will uncomment all the selected lines at once.
Hope this tip helps.