10 Comment Multiple Line in Vim Editor comment | Avoid One by One Comment the Line in Vim

vim comment multiple lines, comment lines in vim,comment multiple lines in vim editor,comment out in vim,vim comment out multiple lines, vim comment
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


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.


To comment out the line

Follow the above Step 2 and Step 3 and then type below command

We can also use c with g for confirmation 


Switch visual block mode by pressing below key from the keyboard

Ctrl  +  v

Now select line which we want to comment out using up/down arrow key

Now we have selected the line so we will press x key from the keyboard to delete the selected character


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.

No comments

Powered by Blogger.