[Apue] Vim Common commands

Source: Internet
Author: User

From: http://coolshell.cn/articles/5426.html

Basic commands:

  • iInsertMode, pressESCBackNormalMode.
  • x→ Delete a character of the current cursor.
  • :wq→ Save disk + exit (:wStorage,:qExit) (Chen Hao note: the file name can be followed after W)
  • dd→ Delete the current row and save the row to the clipboard.
  • p→ Paste clipboard

Simple move cursor

  • 0→ Zero number, to the row Header
  • ^→ The first line of the line is not the position of the blank character (the so-called blank character is space, tab, line feed, carriage return, etc)
  • $→ To the end of the row
  • g_→ The last line is not the position of the blank character.
  • /pattern→ Searchpattern(Chen Hao Note: if multiple matches are found, press n to the next one)

Copy/paste(Chen Hao Note: Both P and P can be used. P indicates that after the current position, P indicates that before the current position)

  • P→ Paste
  • yy→ Copy the current row

Undo/Redo

  • u→ Undo
  • <C-r>→ Redo

Open/Save/exit/change the file(Buffer)

  • :e <path/to/file>→ Open a file
  • :w→ Inventory
  • :saveas <path/to/file>→ Save<path/to/file>
  • :x,ZZOr:wq→ Save and exit (:xSave only when needed. ZZ does not need to enter a colon and press Enter)
  • :q!→ Exit and do not save:qa!Forcibly exit all the files being edited, even if other files are changed.
  • :bnAnd:bp→ You can open many files at the same time and use these two commands to switch to the next or previous file. (Chen Hao Note: I like to use: N to the next file)

Let's take a look at how Vim repeats itself:

  1. .→ (Decimal point) The last command can be repeated
  2. N <command> → repeat a command n times

To make your cursor move more efficiently, you must understand the following commands,Never skip.

  1. NG→ To line N (Chen Hao Note: note that G in the command is capitalized, And I generally use: n to line N, for example, lines 137 to 137th)
  2. gg→ To the first line. (Chen Hao Note: equivalent to 1g, or: 1)
  3. G→ To the last line.
  4. Move by word:
    1. w→ Start with the next word.
    2. e→ To the end of the next word.

The strongest cursor movement:

  • %: The matching brackets are moved, including(,{,[. (Chen Hao Note: you need to move the cursor first to brackets)
  • *And#: Match the current word of the cursor, move the cursor to the next (or the previous) match the word (* is the next, # Is the previous)

You must remember the movement of the cursor, because many commands can be linked with the commands that move the cursor. Many commands can be used as follows:

<start position><command><end position>

For example0y$Command means:

  • 0→ First come to the line Header
  • y→ Copy from here
  • $→ Copy to the last character of the row

 

 

 

 

 

 

 

 

 

 

 

 

D

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.