Vim Common commands

Source: Internet
Author: User

1. move the cursor
Upper: K
Lower: J
Left: l "letter l lower case 』
Right: H
First line of the previous line:-"minus sign 』
First line of the next line: +
First line: 0 "number 0 』
End of line: $
Word tail or the last word tail: E
Next word: W
First or first word: B
Jump to a specific row: row number (: 5: Jump to row 5th)
Last screen: Ctrl + B
Next screen: Ctrl + F
Upper screen: Ctrl + u
Lower half screen: Ctrl + d
Scroll up: CTR + Y
Scroll down: CTR + E
Jump to file header: gg
Jump to the end of the file: G


2. Search
Search in backward mode:/+ Search Mode
Search in forward mode :? + Search Mode
Note: Combine N and N for forward and backward Lookup


3. append or insert
Append the cursor to the Right:
Append at the end of the cursor row:
Append the cursor to the left: I
Append the cursor at the beginning of the line: I "I capital 』
Insert row below the cursor: O [letter O]
Insert rows above the cursor: O [uppercase letters of O]
Insert n to the beginning of m rows #: N, m s/^/#/g "1 to 5 rows, insert Wow: 1, 3 S/^/Wow/G 』
Insert n to m + l row first #: N, + l s/^/#/g "1 to 6 rows, insert row first #: 1, + 5 S/^/#/G 』


4. Delete
Delete cursor: x
Delete cursor left: x
Delete the word where the cursor is located: DW
Delete the current row: dd
Delete cursor to end of line: d $ or d
Delete the current row and the following n-1 rows: NDD "N is a number and the number of rows to be deleted 』
Delete n to m rows: n, m d "delete 1 to 3 rows: 1, 3 D" when m is $, it indicates to the end of the document


5. copy and paste
Copy the word of the cursor: YW
Copy cursor to end of line: Y $ or Y
Copy the current row: yy
Copy rows n times: yyn
Copy the current row and the following n-1 rows: nyy "N is a number and the number of rows to be copied 』
Copy n to m rows and paste it to k + 1 rows: n, m Co K. Copy 1 to 3 rows and paste it to 5th rows: 1, 3, and CO 4 』
Cut n to m rows, paste to k + 1 rows: n, m K "Cut 1 to 3 rows, paste to 5th rows: M 4 』
Paste to the cursor: P
Paste to the cursor: P


6. Undo the reply
Undo: u
Restore: Ctrl + R


7. Replacement
Replace the character of the cursor: R
Replace a word: CW
Replace the first character of the cursor: CB
Replace all the characters from the cursor to the end of the line: C $
Replace current row: CC
Replace the first old of the current row with new: S/old/new
Replace all old values of the current row with new: S/old/new/g.
Replace the first old value from the current row to the last row with new:., $ S/old/new
Replace all old values from the current row to the last row with new:., $ S/old/new/g.
Replace the first old from row n to Row M with new: N, m s/old/new
Replace all old values from row n to Row M with new: N, m s/old/new/g.
Replace the first old of all rows with new: % S/old/new
Replace all old values of all rows with new: % S/old/new/g.


8. Others
View Current Settings: Set all
Show row number: Set nu
Hide row number: Set Nonu
Exit Without saving: Q
Force exit without saving: Q!
Save and edit: W
Save and exit: WQ
Connect the two rows together: J
Concatenates n rows: the row where the NJ cursor is located and n-1-1 row below it
Run the shell command ::! Shell example: view the current time ::! Date
Read the results of shell execution and put the results behind the cursor: R! Shell example: list the files in the directory: R! Ls
Simple encrypted file: x
VIM + N filename open the file filename and place the cursor at the beginning of line N
VIM + filename open the file filename and place the cursor at the beginning of the last line
VIM +/pattern filename open the file and place the cursor in the first serial matching pattern
Vim-r filename was restored at the last Vim crash

Vim Common commands

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.