[VIM] Editor---Multi-line comments and uncomment and multi-line copy and paste

Source: Internet
Author: User

1. Introduction to the VIM editor mode

Vim typically has 4 modes:

    • Normal Mode (Normal-mode)
    • Insert mode (Insert-mode)
    • Command mode (Command-mode)
    • Visual Mode (Visual-mode)

1.1 Normal Mode

Normal mode is generally used to browse files, but also include some copy, paste, delete and other operations. In this case, the general key/key combination will be treated as a function key without typing the corresponding character.

In this mode, we may jump through the text in the keyboard, jumping from small to large are characters, words, lines, sentences, paragraphs and screens.

The default is in normal mode when Vim is started. No matter what mode you are in, pressing the <Esc> button (sometimes pressing twice) will enter normal mode.

1.2 Insert Mode

Insert mode is used to add content to the text, in normal mode, enter the following characters into the insert mode, where the optional insertion method is as follows (common):

    • I start typing text before the cursor character and enter insert mode
    • A enter text after the cursor character and enter insert mode
    • O (Letter O) Enter text in a separate line below the line where the cursor is located and enter into insert mode
    • s delete the character of the cursor and enter insert mode
    • I enter text at the beginning of the line and enter insert mode. This line first refers to the first non-whitespace character. If there is a space at the beginning of the line, enter the text after the space and enter insert mode
    • A enter text at the end of the line and enter insert mode. This works, you don't have to control where the cursor is on this line, just press A will wait for you to enter the text at the end of the row.
    • O (capital letter O) opens a new line above the line of the cursor to enter the text and into insert mode.
    • S delete the cursor line and enter insert mode

1.3 Command mode

In normal mode, pressing the: (colon) key will enter the command mode. In command mode, you can perform some input and execute some of the instructions provided by VIM or plug-ins, just like in the shell. These directives include setting up the environment, file operations, invoking a feature, and so on.

1.4 Visual Mode

In normal mode press V, V, <ctrl>+v, can enter the visual mode.

The visual mode is equivalent to the normal mode after highlighting the selected text.

"V" or "Shift+v": The visual line pattern selected by the behavior unit;

"Ctrl + V": a block-based visual block mode for selection;

2. Multi-line simultaneous annotation

    • Press CTRL + V to enter the column mode;
    • Select the line you want to annotate at the beginning of the row;
    • Press "I" to enter insert mode;
    • Then enter the comment symbol ("//", "#", etc.);
    • Press the "ESC" key.

3. Canceling multiple lines of comment

    • Press CTRL + V to enter the column mode;
    • Select the comment you want to cancel;
    • Press "X" or "D".

4. Multi-line replication

In the mode, select the text;

Input character: "yy" (Yank), complete the copy;

Move to the location where you want to insert the text, and in normal mode, enter the character: "P".

  

[VIM] Editor---Multi-line comments and uncomment and multi-line copy and paste

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.