Vim Comment multiple lines - Vim comment out multiple lines |
In this topic we will comment the multiple line with the help of visual mode. it will be helpful where we want to comment multiple lines doing this topic we can save time by comment multiple line instead of comment one by one.
1 - We will open a file where we want to comment
vi /tmp/lokesh
2 - Switch in visual mode
Shift + v
We will select line in visual mode using up and down arrow key or j,k key.
In above screenshot we are in visual mode and selected a 5 lines
3 - Comment above 5 lines by Switching command line mode
Shift + :
4 - Type
s/^/#/g
Here, s for the search, caret ( ^ ) matches the beginning of the line, # is character for comment the line, and g stands for global, which means that all matching occurrences in the line would be replaced. all 4 task divided by shash (/).
We can also use c with g keyword for confirmation to add # in every line, suppose we want to keep 3 line as it is.
s/^/#/gc
To comment out the line
Follow the above Step 2 and Step 3 and then type below command
s/#//g
We can also use c with g for confirmation
OR
Switch visual block mode by pressing below key from the keyboard
Ctrl + v
Now we have selected the line so we will press x key from the keyboard to delete the selected character
x
Thanks you !!
I hope this topic gave you all the information you needed. If you have any further questions or would like more detailed directions feel free to contact us using any of the following sources.We look forward to talking to you.
Nice post. I was checking constantly this blog and I’m impressed! Extremely useful info specially the last part I care for such information a lot. I was seeking this certain info for a long time. Thank you and good luck.collapsed sewer line
ReplyDeleteAdobe-Illustrator-CC-Serial Key is an essential part of our lives. We use it in our homes and offices for personal and professional use. Although a lot of software is paid and some are free. But you can download any crack software from our site.
ReplyDeleteVery glad I finally found this site. Really informative, thanks for the post and effort! Please keep sharing.PVSOL Premium 2022 Crack
ReplyDelete