Vim common commands at a glance

Source: Internet
Author: User

Insert Directive

I insert a character at the cursor

I Insert a character prompt the first non-whitespace character in the row of the cursor

o Insert a row below the light table

O Insert a row above the line where the cursor is located

R replaces the character of the cursor, replacing it only once

R replaces the character at the cursor and knows to press ESC

Jump Instructions

0 jump to the beginning of the line where the cursor is

$ jump to the end of the line where the cursor is

n< SPACEBAR > Jump n characters from the beginning of the cursor

G jumps to the beginning of the last line

NG jumps to nth row

GG jumps to the beginning of the first line

N<enter> jumps to n rows from the line where the cursor is located

Delete directive

x Delete the character of the cursor

X delete the preceding character of the cursor

DD deletes the cursor in the row

NDD removes n rows from the line where the cursor is located

D1G from the line where the cursor is located, delete up to the first row

DG starts at the line where the cursor is located and drops down to the last row

D0 from the cursor position until the start of the bank

D$ from the beginning of the cursor to the end of the bank

Copy and paste instructions

YY Copy Bank

Nyy starts at the line where the cursor is located, copying the n rows down

Y1G from the line where the cursor is located, copy up to the first row

YG starts at the line where the cursor is located and copies down to the last row

Y0 start at the cursor position and copy to the bank

y$ from cursor position, copy to end of bank

P Paste the copied content below the line where the cursor is located

P paste the copied content on top of the line where the cursor is located

Find replacement directives

/word search for Word from the cursor

Word from the cursor to search for Word

: N Continue looking down

: N continue looking down

: n1,n2s/word1/word2/g Replace the word N1 line to N2 line word1 all with Word2

: N1,N2S/WORD1/WORD2/GC the word word1 from line N1 to N2 is replaced with Word2, and user confirmation is required and C is the meaning of confirm

Save Instructions

: w filename

Undo and redo Instructions

U Undo command, undo previous action

Ctrl+r Redo instructions, redo previous action

Connection Instructions

J connect the cursor row and the next line to the same row

: R filename reads the file filename and adds the contents of the filename to the line following the cursor

Shell Command Command

:! Shell command runs shell commands in vim

Multiple file editing instructions

Vim filename1 filename2 ... Open multiple files at the same time in vim

: Files lists all open files

: N View Next file

: N View Previous file

Multi-window editing instructions

: SP filename also opens multiple vim windows to browse the file, and if you omit filename, the same file is browsed

Ctrl+w+j (down arrow) cursor moves to the next window

Ctrl+w+k (up ARROW) cursor moves to the previous window

Block selection directives

V The character of the cursor passing the anti-white selection

V Select the line that the cursor is passing through

CTRL + V selects the characters passed by the cursor in a rectangular region

Y Copy the selected chunk

P Paste the copied chunk at the cursor

D Delete the selected chunk

Auto-Complete instructions

Ctrl+x->ctrl+n first Press CTRL+X, then press CTRL + N, based on the contents of the file being edited to complete the automatic completion

Ctrl+x->ctrl+o Press Ctrl+x First, then press Ctrl+o to complete auto-completion according to the file suffix being edited

Vim common commands at a glance

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.