The summary of the better Vim commands

Source: Internet
Author: User

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 the keyword * or G * Before the cursor *

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 the key next to 'x, 1 at a tag

11. Move to the Last edited file location '.

PS:. represents an arbitrary character * represents the repetition of one or more characters

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 in the selected block I <string> ESC

 

7. Jump to Declaration

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.

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.