When using the Vim editor, it is sometimes necessary to annotate or annotate multiple lines of code, unlike we need to enter our own command operations, as in the case of VS, and two methods are described below. Method One: Block selection mode 1. Insert Note (1) First press ESC on the keyboard to enter the command line mode (2) and press CTRL + V to enter the visual block mode (3) Use the next key to adjust the number of lines to comment and the width of the line (4) and then press Shift+i or S into insert mode (5) to enter the symbol for the comment, such as # (6) Press ESC again, then you can complete multiple lines of comments (may need to wait a while, do not worry) 2. Go to comment The first three steps are the same as the comment. (1) First press ESC on the keyboard to enter the command line mode (2) and press CTRL + V to enter the visual Block Mode (3) using the next key adjustment needs to comment on how many lines and the width of the line (4) and then press D to complete the annotation method two: Replace the command 1. Insert Note (1) First press ESC on the keyboard to enter command line mode (2) and enter the following command on the bottom line: Start line number, end line number s/^/ /g before inserting comments: After inserting comments: The bottom row shows a total of a few lines inserted in Note 2. Go to comment (1) First press ESC on the keyboard to enter the command line mode (2) and enter the following command on the bottom line: Start line number, end line number s/^ comment// G to comment before: After the comment: After removing the comment, the bottom line shows that a few lines of comments are removed altogether
Vim Editor-Multiple lines with comments and comments