Vim's bulk comment and delete commentMethod One: Block selection mode
Bulk Comment:
Ctrl + V into block selection mode, then move the cursor to select the line you want to comment, and then press the uppercase I into the beginning of the insertion mode enter the comment symbol such as//or #, after the input is complete, VIM will automatically add all the lines of your selected capital annotated.
Uncomment:
Ctrl + V Enter block selection mode, select the comment symbol for the beginning of the line you want to delete, note//To select two, then press D to delete the comment.
Method Two replace command
Bulk Comment:
Use the following command to add comments at the beginning of the specified line:
: Starting line number, ending line number s/^/comment/g
Uncomment:
: Starting line number, ending line number s/^ comment//g
Example:
Add//comment on line 10-20
: 10,50s#^#//#g
Delete//comment on line 10-20
: 10,20s#^//# #g
Add # comments To line 10-20
: 10,20s/^/#/g
Delete # comments on line 10-20
: 10,20s/^/#/g
Note that the example of a regular divider uses the opposite symbol, and if the match//is used #Make a separator so you don't need to/as Escape, save the number of inputs
Vim's bulk comment and delete comment