Linux--vim Common operations

Source: Internet
Author: User

Linux--vim Common operations

Insert command:

Command Role
A Insert the word specifier where the cursor is located
A Insert at the end of the line where the cursor is
I Insert in the word match either the cursor
I Insert before the cursor is in the row
O Insert a new line under the cursor
O Insert a new line on the cursor

Locate command:

                    

Command Role
: Set Nu Set line number
: Set Nonu Cancel line number
Gg To the first line
G To the 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:

                

Command Role
X Delete the character at the cursor location
Nx Delete n characters after cursor location
Dd Delete the row where the cursor is located, ndd delete n rows
Dg Delete the line from the cursor to the end of the file
D Delete the cursor at the end of the line
: n1,n2d

Delete a specified range of rows

copy and cut commands:

      

Command Role
Yy Copy when moving forward
Nyy Copy Current row n rows
Dd Cut when moving forward
Ndd Cut the current row n rows
P,p

Paste at the current cursor row or line

Replace and Cancel commands:

      

Command Role
R Replaces the character at which the cursor is located
R Start with the cursor where you know to press ESC to end
U Cancel the previous action

Search and search Replacement commands:

              

Command Role
/string

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 Replace all specified strings
: n1,n2s/old/new/g Replace a specified string within a certain range

Save and Exit Commands:

              

Command Role
: W Save changes
: w New_filename Save as specified file
: Wq Save changes and exit
Zz Shortcut keys, save changes and launch
: q! Do not save changes to exit
: wq! Save changes and exit (file owner and root can be used)

Import command execution result: R! Command

Define shortcut keys: Map shortcut Trigger command

Example:: Map ^p i#<esc>

: Map ^b 0x

Continuous line Comment: n1,n2s/^/#/g

: n1,n2s/^#//g

: n1,n2s/^/\/\//g

Replacement: AB mymail [email protected]

Linux--vim Common operations

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.