Vim frequently used commands (Refresher version)

Source: Internet
Author: User

Original link: http://blog.csdn.net/love__coder/article/details/6739670

1. Cursor movement

Top: K

Under: J

Left: L "Letter L lowercase"

Right: H

Beginning of previous line:-"Minus"

The beginning of the next line: +

Beginning of line: 0 "number 0"

End of line: $

The ending of a word or the last word: E

The first word of the word: w

The first or last word of a word: b

Jump to a specific line:: Line number (: 5: Jump to line 5th)

Previous screen: Ctrl + B

Next screen: Ctrl + F

Upper Half Screen: Ctrl + U

Lower half Screen: Ctrl + D

Scrolling up: Ctr + y

Scrolling down: Ctr + E

Skip to file header: GG

Skip to end of file: G

2. Search

Backward mode search:/+ search mode

Forward mode search:? + Search Mode

Note: Combine n and N to find forward backwards

3. Append or Insert

Append to right of cursor: a

Cursor Line END Append: A

Append to left of cursor: I

Append to the beginning of the cursor: uppercase of I "I"

Insert line below cursor: o "Letter O"

Insert line above cursor: o "uppercase of Letter O"

N to M line header Insert #:: N,m s/^/#/g "1 to 5 lines, beginning of insertion wow:1,3 s/^/wow/g"

N to M+l line header Insert #:: N,+l s/^/#/g "1 to 6 lines, beginning of insertion #: 1,+5 s/^/#/g"

4. Delete

Delete cursor: x

Delete cursor to the left: X

Delete the word where the cursor is located: DW

Delete Current line: DD

Delete cursor to end of line: d$ or D

Delete the current row and the following n-1 line: NDD "N is a number, is the number of rows to be deleted"

Delete N to M line:: N,m D "Delete 1 to 3 rows: 1,3 D" When M is in $, indicates to end of document

5. Copy and paste

Copy the word that is located in the cursor: YW

Copy cursor to end of line: y$ or Y

Copy Current line: yy

Copy Rows n times: Yyn

Copy the current row and the following n-1 line: Nyy "N is a number, is the number of rows to be copied"

Copy N to M line, paste to K+1 line:: N,m co k "copy 1 to 3 lines, paste to line 5th: 1,3 Co 4"

Cut N to M line, paste to K+1 line:: n,m m K "Cut 1 to 3 lines, paste to line 5th: 1,3 M 4"

Paste to the cursor: p

Paste to Cursor: P

6. Withdrawal of reply

Undo: U

Recovery: Ctrl + R

7. Replace
Replace the character where the cursor is located: R
Replace one word: CW
Replace the previous character of the cursor: CB
Replace all characters from the cursor to the end of the line: C $
Replace current line: CC
Replace the first old of the
current line with the new:: S/old/new
Replace all
old for the current line with new::s/old/new/g
replace the current line to the last row of the first old to new::., $s /old/new
Replace the current line to the last row of all old for new::., $s/old/new/g
replace the
first old of line N to row M with the new::n,m s/old/new
Replace All old of row N to line M new::n,m s/old/new/g
replaces all rows of the first old with new::%s/old/new replaces all old for all rows with new::%s/old/new/g

8. Other

View current settings:: Set all

Display line number:: Set Nu

Hidden line number:: Set Nonu

Do not save exit:: Q

Do not save forced exit:: q!

Save edits:: w

Save and exit:: Wq

Connect the two lines together: J

Connect n rows together: NJ cursor row and next n-1 line

Execute shell command::! Shell For example: View the current time::! Date

Read the results of the shell execution and place the result behind the cursor:: R!shell For example: List files in directory:: R!ls

Simple Encrypted File:: X

Vim +n filename Opens the file filename and places the cursor at the beginning of the nth line

Vim + filename Opens the file filename and places the cursor at the beginning of the last line

Vim +/pattern filename Opens the file and places the cursor in the first serial that matches the pattern

Vim-r filename recovers filename at the last vim crash

Vim Common Commands (review version) (GO)

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.