Vim's Operation

Source: Internet
Author: User

Position command

Command function

H Move one character to the left

J Move down one line

K Move up one line

L Move one character to the right

$ move to end of line

0 Move to the beginning of the line

H move to upper screen

M moves to the center of the screen

L Move to the bottom of the screen

Quick positioning

Command function

: Set nu Displays line number

: Set Nonu Cancel line number

GG move to first line

G move to last line

NG to Nth row

: N to nth row

Delete command

X Delete the character of the cursor

NX Delete n characters

DD Deletes the row where the cursor is located, NDD deletes n rows

DG Deletes all rows from the current line to the end of the file , including the current row

D Delete the contents of the cursor at the end of the line

: n1,n2d Delete n1~n2 line

Copy command

yy copy when moving forward

Nyy,ny copy n rows

DD cuts the current line, NDD cuts the current row and N rows

P pasted below the current line

p[uppercase] pasted on the current line

Replace or Cancel command

R replaces the character at which the cursor is located

R replaces the character at the cursor position until ESC ends

You cancel the previous operation, first you have not saved, the document is still in memory, has not synced to the hard disk.

Replace or Search command

/string Searches backward for the specified string, ignoring case when searching: Set IC, Cancel: Set Noic

N from head to back

n turn from back to forward

:%s/old/new/g Full text replaces the specified string, old is the keyword that needs to be replaced.

: n1,n2s/old/new/g replaces specified string within a certain range

:%s/old/new/C replaces the specified string with the full text, but asks

Save and exit

ZZ: shortcut keys for Wq

: w new_filename Save as specified file

: wq! Forcibly save changes and exit [root/file owner]

: q! do not save exit

Continuous line Comment

: n1,n2/^/#/g#在n1到n2行的行首加 #

: n1,n2/#//g#去掉n1到n2行行首的 # Remove


This article from "All Technical Blog" blog, reproduced please contact the author!

Vim's Operation

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.