Vim Document editing

Source: Internet
Author: User

1 repeating last command

In normal mode . (decimal point) means the last command operation is repeated

Normal mode input x , delete the first character, the input . (decimal point) will be deleted again a character, in addition to also can be repeated dd delete operation

2. Execute commands of the same number of times

Enter Normal mode input N<command> , n indicates the number of repetitions, and the following is the practice:

Do the following exercises:

    • Input 10x , delete 10 consecutive characters
    • Input 3dd , 3 lines of text will be deleted

In normal mode, you can also dw daw delete a word with or (delete a word), so you can easily associate (n with the dnw corresponding number ) to delete n words

Ii. Quick jump of cursors

In normal mode, the following command allows the cursor to be quickly reversed to the specified position, we discuss the rapid implementation of the inline jump and in-line jump

1. Jump between rows
Command Description
nG(n shift+g) Cursor moves to nth row (if no line number is displayed by default, enter command mode first :set nu to display line numbers)
gg Cursor moves to the first row
G(SHIFT+G) To the last line

Open the practice document using Vim, and then do the following exercises:

    • Quickly jump to line 9th and delete the row
    • Go back to the first line, delete 8 rows down
    • Jump to the end of the document and delete the row

tip: After you have completed the jump, you can use the Ctrl+o quick to go back to the previous (before the jump) cursor position , this technique is very practical, such as when you write code, suddenly think of a bug, need to change, this time you jump over to change, just need to press Ctrl+o You can go back to where you were before. Vim will be waiting for you to explore with a lot of similar tips.

2. In-line jump

In normal mode, use the following command to jump within a line in a word

Command Description
w To the beginning of the next word
e To the end of the next word
b To the beginning of the first word
ge To the end of the previous word
0Or^ to the wardrobe.
$ To end of line
f<字母> Search backwards < letters > and jump to the first matching position (very useful)
F<字母> Search forward < letters > and jump to the first matching position
t<字母> Search backwards < letters > and jump to a letter before the first matching position (not used)
T<字母> Search forward < letter > and jump to a letter after the first matching position (not used)

Do the following exercises in turn:

    • In normal mode, jump to a line, use w jump to the beginning of a word, and then use dw the word delete
    • In normal mode, use e jump to the end of a word and use ~ the letter that contains the cursor to capitalize or lower case

Third, copy paste and cut 1. Copy and paste text
    • Use replication in normal mode y

      • In normal mode, yy the entire line where the cursor is copied ( 3yy representing the replication of 3 rows)
      • In normal mode, y^ copy to the beginning of the line, or y0 . Does not contain the character at which the cursor is located.
      • In normal mode, y$ copy to end of line. The character where the light is contained.
      • In normal mode, yw copy a word.
      • In normal mode, y2w copy two words.
      • In normal mode, yG copy to the end of the text.
      • In normal mode, y1G copy to the beginning of the text.
    • Use paste in normal mode p

      • In normal mode, p (lowercase) represents pasting to the cursor (bottom)
      • In normal mode, P (uppercase) means pasting to the front of the cursor (top)

Open the file into normal mode practice the above command, you can now feel free yy to

$ vim protocols
2. Cut and paste

In fact, the dd deletion of the command is cut, each time you dd delete the contents of the document can be used p to paste, also this allows us to achieve a very refreshing function--exchange up and down line: ddp , it is so simple, that is, the implementation of the fast Exchange cursor line with the line below it

Vim Document editing

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.