Vim Editor Commands

Source: Internet
Author: User

Introduction to Vim

Vim (vimsual) is a universal full-screen editor in the Linux/unix series OS.

Vim is divided into two states, the command state and the editing state, in the command state, the character system typed as a command, such as: Q for Exit, and the editing state is used to edit the text data. When you enter vim, the command state is entered first. In the command state, press "I" (insert) or "a" (add) can enter the editing state, in the editing state, press Esc key to enter the command state.

In the command state, there are some common commands:

New:

A add text from behind the cursor

A adds text starting at the end of the line where the cursor is located

Insert:

I insert text starting at the front of the cursor

I insert text from the beginning of the line where the cursor is located

Delete and modify:

X Delete the character at the cursor

DD Delete the entire line where the cursor is located

3DD Delete the row of the cursor and the following two lines

D Remove text from the cursor to the end of the line

Cursor Movement:

^ cursor moves to the beginning of the line

$ cursor moves to the end

GG cursor navigates to document header

G cursor navigates to end of document

W cursor moves backward one word

b cursor move forward one word

[n]+ cursor moves backward n rows, [n] represents an integer

[n]-cursor moves forward n rows

N The G cursor is positioned at the beginning of the nth line and [n] represents an integer

Find and replace

/[STR] Find string Str,[str] represents the string to find, the carriage return will highlight all found strings, then command n moves to the next found string, command n moves to the last found string

Partial substitution (can only replace the row where the cursor is located)

: S/[SRC]/[DST]/I (Ignore case)/g (all matches) Eg:s/hello/world/ig replace line

: 3,6 s/[src]/[dst]/ig (Find in 3-6 rows) eg:3,6 S/hello/world Replace All

Replace All

:%s/[src]/[dst]/g replaces all SRC strings in the document with the DST string

:%s/^//g the space at the beginning of each line of the document

Block operation

V Visualize block selection state, after the block is selected, the block can be deleted (d), copied (y), cut (x)

yy the entire line where the cursor is copied

[N]yy copies n rows from the beginning of the cursor, [n] represents an integer

P Paste the copied text at the cursor

U Undo Last Action

End Edit:

: Q Exits if the document is not modified

: q! Discard changes to the document and forcibly exit

: W Document to disk

: Wq document to log out

Vim Editor 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.