Complete vim shortcut keys and complete vim shortcut keys

Source: Internet
Author: User

Complete vim shortcut keys and complete vim shortcut keys

I have been studying for a long time in Linux, but I am still a primary school student. Alas, I shared the vim commands in linux, with these shortcuts, I believe everyone will be able to learn in linux.

I. move the cursor
1. Shift left h, move right l, move down j, move up k
2. Flip down ctrl + f, flip up ctrl + B
3. Flip down half page ctrl + d, flip up half page ctrl + u
4. Move to the end of the line $, move to the first 0 (number) of the line, and move to the first character of the line ^
5. move the cursor to the next sentence) and move the cursor to the previous sentence (
6. Move to the beginning of the field {, move to the end of the field}
7. Move to the next word w and the previous word B.
8. Move to document start gg, move to document end G
9. Move to the matched {}. (). [] at %
10. Jump to line n ngg or nG or: n
11. move the cursor to the top of the screen H, move the cursor to the middle of the screen M, and move the cursor to the bottom L
12. Read the current character and move it to the next place on the screen *
13. Read the current character and move it to the last place on the screen #

2. search and replace
1. Search for keywords by cursor # Or g #
2. Search for keywords with the cursorOr g
3. Search for characters fx, Fx, tx, and Tx in the current row.
4. Basic replacement: s/s1/s2 (replace the next s1 WITH s2)
5. replace all: % s/s1/s2
6. Replace the current row only: s/s1/s2/g
7. replace some rows: n1, n2 s/s1/s2/g
8. The search mode is/string. the next field is n, and the last field is N.
9. Create a bookmarks mx, but do not see the bookmarks. Only lowercase letters can be used.
10. Move to a tagKeys next to x and 1
11. Move to the last file edited
.

PS:. represents an arbitrary character * represents the repetition of one or more characters
The content of the regular expression will be sorted out in subsequent articles.

3. Edit operations
1. Insert a after the cursor and insert A at the end of the row
2. Insert one row to the end, and insert one row to the front.
3. Delete the characters inserted into s and delete the inserted S in the positive line.
4. insert I before the cursor and insert I at the beginning of the line
5. delete a row of dd. After deletion, enter the insert mode cc or S.
6. delete a word dw and delete a word to enter the insert mode cw
7. delete a character x or dl, and delete a character to enter the insertion Mode s or cl.
8. paste p, exchange two characters xp, and exchange two lines of ddp.
9. Copy y and copy a row of yy
10. Undo u, redo ctrl + r, and repeat.
11. intelligently prompt ctrl + n or ctrl + p
12. Delete the characters crossed by motion and enter the insertion mode c {motion}
13. Delete the character that spans the next character. Delete the character and enter the insert mode, excluding x ctx.
14. Delete All characters from the current character to the next character, and enter the insert mode, including the x character, cfx
15. Delete the character crossed by motion, delete it, but do not enter the insertion mode d {motion}
16. Delete the characters crossed by motion. Delete the characters but do not enter the insert mode, excluding the x-character dtx.
17. Delete All characters from the current character to the next character, including the x character dfx
18. If only copying is required, change c or d from 12-17 to y.
19. You can use D or C to delete it to the end of a row.
20. Copy the current row yy or Y
21. Delete the current character x
22. paste p
23. You can use multiple clipboard to view the status using reg and clipboard, for example, copying to w register, "wyy, or using visual mode v" wy
24. Repeat the previous function.
25. A number can be used to span n areas, such as y3x. the area between the cursor and the third x is copied, and 3j moves three rows down.
26. You can use] p to paste the code when writing it, so that the code can be automatically indented.
27.> indent all selected Codes
28. <unindent all selected Codes
29. Move gd to the definition of the function or variable where the cursor is located.
30. K searches man for words with the cursor
31. merge two rows J
32. If you do not want to save the file, open it again: e!
33. To open a new file: e filename, use ctrl + ^ to switch the file.

Iv. window operations
1. Separate a window: split or: vsplit
2. Create a window: new or vnew
3. open the file sf {filename} in a new window}
4. close the current window: close
5. retain only the current window: only
6. ctrl + w, h in the left-side window
7. ctrl + w, l in the right window
8. Press ctrl + w, k in the upper window.
9. Press ctrl + w, j
10. ctrl + w, t at the top of the window
11. ctrl + w, B at the bottom of the window

5. Macro operations

1. Start recording macro Operation q [a-z], press q to end, and save the operation to register [a-z ].
2. @ [a-z] execute the operation in the register [a-z]
3. @ execute the macro operation of the last record

Vi. Visual operations

1. Enter block visual mode ctrl + v
2. Enter the character visual mode v
3. Enter the line visual mode V
4. Delete the selected block d.
5. Delete the selected block and enter the insert mode c.
6. Insert the same character IESC to the selected block

VII. Transfer statement

1. [[jump forward to the first entry of the top {
2. [] Jump forward to the first entry in the top level}
3,] jump back to the first {
4,] Jump backward to the first of the top}
5. [{jump to the beginning of the code block
6.]} jump to the end of the code block

8. Pending operations

1. suspend Vim ctrl + z or: suspend
2. View task input jobs in shell
3. Restore task fg [job number] (put the background program to the foreground) or bg [job number] (put the foreground program to the background)
4. Run the shell command :! Command
5. Enable the shell command: shell. exit the shell exit.
6. Save the vim status: mksession name. vim
7. Restore vim: source name. vim
8. The vim-S name. vim state is restored when vim is started.

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.