Vim Editor Common commands

Source: Internet
Author: User
Tags first string

One. Cut:

1. To delete from the current cursor to the next word, enter: DW
2. To delete from the current cursor to the end of the current line, enter: d$
3. To delete the entire row, enter: DD//can use DND to delete multiple rows n for the number of rows
4. To repeat an action, precede it with a number: 2w
5. The format for modifying commands in normal mode is:
operator [NUMBER] Motion
which
Operator-operators, which represent things to do, such as D for deletion
[NUMBER]-numbers that can be appended, representing the number of times the action repeats
Motion-action, which represents the movement of the text on which it is manipulated, such as w for word (word),
$ represents the end of the line and so on.

Two. Revocation

    1. To undo a previous operation, enter: U (lowercase u)
    2. To undo the changes you made in one line, enter: U (uppercase U)
    3. To undo the previous Undo command and restore the previous operation results, enter: Ctrl-r

Three. Copy and paste

    1. Press the operator v when copying and select the text you want to copy under the visual interface.
    2. Operator y copies the text and p pastes the previously copied text.

Four. Jump

    1. The ctrl-g is used to display the current cursor location and file status information.
    2. G is used to jump the cursor to the last line of the file.
    3. Type a line number first and then enter uppercase G to move the cursor to the line represented by the line number.
    4. GG is used to jump the cursor to the first line of the file.

Five. Search matches

    1. The input/Then followed by a string is the string that is found in the currently edited document.
    2. Input? followed by a string is the reverse lookup of the string in the currently edited document.
    3. Pressing the N key after a search is done repeats the last command and can be checked in the same direction
    4. Find the next matching string, or in the opposite direction of uppercase N to find the next matching string.
    5. If the current position of the cursor is parentheses (,), [,], {,}, pressing% will move the cursor to the pair of parentheses.

Six. Replace

    1. Replace the first string in a line with old as the new string, enter: S/old/new
    2. Replace all of the strings in a row with old as the new string, please enter: s/old/new/g
    3. Replace all the strings in the two lines with old for the new string, enter: #, #s/old/new/g
    4. Replace all the strings in the file with old for the new string, please enter:%s/old/new/g
    5. Ask the user to confirm that each replacement needs to be added with the C flag:%S/OLD/NEW/GC//full-text replacement recommended

Seven. Text modification (insert mode)

    1. Enter lowercase r to replace a single character under the cursor.
    2. Enter the uppercase R to enter the replacement mode until you press <ESC> to return to normal mode.

Eight. Auto-complete

    1. Ctrl-n from the top down
    2. Ctrl-p from bottom to top

Nine. Execute external commands in VIM mode

Take a look at some practical examples:
(MS-DOS) (Unix)
:!dir:!ls-Used to display the contents of the current directory.
:!del filename:!rm filename-Used to delete a file named filename.

Vim Editor Common commands

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.