Common commands for Linux vim file editing

Source: Internet
Author: User

Vim's working mode is first to know:

In command mode, enter I a o:
A insert after the character where the cursor is located
A at the end of the line where the cursor is inserted
I insert the word match either the cursor
I Insert at the beginning of the cursor
o Insert a new line under the cursor
O insert a new line on the cursor
The main case is different.

 Locate command:

: Set Nu Sets line number
: Set Nonu Cancel line number
GG to First line
G to last line
NG to Nth row
: N to Nth row

$ move to end of line
0 move to the beginning of the line

  Delete command:

X Delete the character at the cursor location
NX removes the n characters after the cursor is located
DD Delete Row of cursor, NDD delete n rows
DG removes the line from the cursor to the end of the file
D Delete the cursor at the end of the line
: n1,n2d Delete rows in a specified range

Copy and cut commands:

YY copy when moving forward
Nyy Copy the current row following n rows
DD Cut when moving forward
NDD cuts n rows below the current line
P, p pasted under the current cursor row or line

Search command:


Search for a specified string
Ignore case when searching: Set IC
n searches for the next occurrence of the specified string
:%s/old/new/g full text Replace specified string
: N1,n2s/old/new/g replaces specified string within a certain range

Replace and Cancel commands:

R replaces the character at which the cursor is located
R replaces the character at the beginning of the cursor and presses ESC to end
U Cancel the previous action

Save and Exit Commands:

: W Save changes
: W new_filename Save as specified file
: Wq Save changes and exit
ZZ shortcut keys, save changes and exit
: q! Do not save changes to exit
: wq! Save the changes and exit (the former modification, in the absence of write permission, only the owner of the file and root can be used)

  

Common commands for Linux vim file 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.