Vim shortcut Key Finishing

Source: Internet
Author: User

First, move the cursor

1, left shift H, right shift L, Move down J, move up K

2. Page Down CTRL + F, PAGE up Ctrl + B

3. Turn down half a page Ctrl + D, turn up half a page Ctrl + U

4, move to the end of the line $, move to the beginning of 0 (number), move to the first character at the beginning ^

5, move the cursor to the next sentence), move the cursor to the previous sentence (

6. Move to the beginning of paragraph {, move to end of paragraph}

7, move to the next word w, move to the previous word b

8. Move to the beginning of the document GG, move to the end of the document G

9. Move to the matching {}. (). [] Place%

10. Jump to Nth line ngg or NG or: n

11. Move the cursor to the top of the screen h, move to the middle of the screen m, move to the bottom L

12. Read the current character and move to the next occurrence in this screen *

13. Read the current character and move to the last occurrence in this screen #

Second, find and replace

1. Search for keywords #或者g the cursor backwards #

2. Cursor forward to find keywords * or g*

3. The current line looks for characters FX, FX, TX, TX

4. Basic Replacement: S/S1/S2 (replace the next S1 with S2)

5. Replace All:%S/S1/S2

6. Replace the current line only: s/s1/s2/g

7. Replace some lines: n1,n2 s/s1/s2/g

8, search mode for/string, search for the next n, search for the previous n

9, make bookmarks MX, but do not see bookmark tags, and can only use lowercase letters

10. Move to the key next to ' x,1 ' at a label

11. Move to the location where you last edited the file.

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

The contents of the regular expression will be sorted in subsequent articles

Third, editing operations

1. Insert a after the cursor, insert a at the end of the line

2. Insert a line after inserting O, insert a line into O

3. Delete character Insert S, delete positive row insert S

4, insert before the cursor I, the beginning of insertion I

5, delete a line of DD, delete after entering the insert mode cc or S

6. Delete a word dw, delete a word into insert mode CW

7, delete a character x or DL, delete a character into insert mode S or CL

8, paste p, exchange two characters XP, exchange two lines DDP

9, copy y, copy a line yy

10, Undo U, redo Ctrl + R, repeat.

11. Smart Tips CTRL + N or CTRL + P

12. Delete the character that motion crosses, delete and enter insert mode C{motion}

13. Delete the character that crosses the next character, delete and enter insert mode, not including the X character CTX

14. Remove all characters from the current character to the next character and enter insert mode, including the x character, CFX

15. Delete the character that motion crosses, delete but do not enter insert mode D{motion}

16. Delete the character that motion crosses, delete but do not enter insert mode, do not include X character DTX

17. Delete all characters at the current character to the next character, including the X character DFX

18, if only copy of the case, the 12-17 in the C or D is changed to Y

19, delete to the end of the line can use D or C

20, copy the current line yy or Y

21. Delete the current character X

22. Paste P

23, you can use the multi-shear board, check the status using: Reg, use the clipboard using ", such as Copy to W Register," Wyy, or use visual mode V "WY

24. Repeat the last action used.

25, using the number can cross n regions, such as y3x, will copy the cursor to the third x between the area, 3j down 3 lines

26, when writing code can use]p paste, so that you can automatically indent the code

27. >> Indent All selected code

28. << Indent All selected code

29. GD moves to the definition of the function or variable where the cursor is located

30, K in man search for the word cursor

31, merge two lines J

32. If you do not want to save the file and reopen: e!

33. If you want to open a new file: E filename, then use CTRL + ^ for file switching

Four, window operation

1. Separate a window: Split or: Vsplit

2. Create a window: New or: Vnew

3. Open the file in a new window: SF {filename}

4. Close the current window: close

5. Keep only the current window: only

6, to the left window Ctrl + W, h

7, to the right window Ctrl + W, l

8, to the top window Ctrl + W, K

9, to the bottom of the window Ctrl + W, J

10. Top Window Ctrl + W, t

11, the bottom of the window Ctrl + W, b

Five, macro operation

1. Start recording macro Operation Q[a-z], press Q to end, save operation to register [a-z]

2, @[a-z] perform operation in register [a-z]

3. @@ 执行 The last recorded macro operation

VI. Visual operation

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 insert mode C

6. Insert the same character in the selected block I<string>esc

Vii. Skip to Declaration

1, [[Forward Jump to the top of the first {

2, [] jump forward to the top of the first}

3,]] jump back to the top of the first {

4,]] jump back to the top of the first}

5, [{Jump to the beginning of this code block

6,]} jumps to the end of this code block

Eight, suspend operation

1. Hang Vim Ctrl + Z or: Suspend

2. View tasks enter jobs in the shell

3. Restore the task FG [job number] (place the daemon in the foreground) or BG [job number] (put the foreground program in the background)

4. Execute shell command:!command

5. Open shell command: Shell, quit the shell exit

6. Save Vim State: Mksession Name.vim

7. Restore VIM Status: Source Name.vim

8. Restore status when VIM is activated vim-s Name.vim

Vim shortcut Key Finishing

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.