Original address: http://www.libenfu.com/vim-shortcut key Finishing
As a back-end code farming, the most commonly used is vim
, then vim
the common shortcut keys, you know how much?
Move cursor
1. Move left, h
right l
, Move down, move j
upk
2. Page Down ctrl + f
, PAGE upctrl + b
3, turn down half page ctrl + d
, turn up half pagectrl + u
4, move to the end of the line, move to the $
beginning 0
(number), move to the beginning of the first character^
5, move the cursor to the next sentence )
, move the cursor to the previous sentence(
6, move to the beginning {
of the paragraph, move to the end of the paragraph}
7, move to the next word w
, move to the previous wordb
8. Move to the beginning gg
of the document and move to the end of the documentG
9. Move to the matching {}.().[]
place%
10. Jump to the first n
line ngg
or nG
:n
11. Move the cursor to the top of the screen, move to the H
middle of the screen M
, move to the bottomL
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#
Find replacements
1. The cursor looks backwards for keywords #
org#
2, the cursor forward to find the keyword *
org*
3. The current line looks for charactersfx/Fx/tx/Tx
4. Basic substitution s/s1/s2
(replace next s1
to s2
)
5. Replace All%s/s1/s2
6, only replace when the forwards/s1/s2/g
7. Replace some linesn1,n2 s/s1/s2/g
8, search mode for /string
, search the next place for n
, search the previous place forN
9, make bookmarks mx
, but do not see bookmark marks, and can only use lowercase letters
10. Move to a label`x
11. Move to the location where you last edited the file`.
. 代表一个任意字符* 代表一个或多个字符的重复
Edit operation
1, after the cursor insertion a
, line end insertionA
2, after inserting a line inserted o
, the front plug a row insertO
3. Delete character Insert s
, delete positive row insertS
4, inserted before i
the cursor, the beginning of the insertionI
5, delete dd
a row, after deleting into insert mode cc
orS
6. Delete a word dw
and delete a word into insert modecw
7, delete a character x
or dl
, delete a character into the insert mode s
orcl
8, Paste p
, exchange two characters xp
, exchange two linesddp
9, copy y
, copy a rowyy
10. Undo u
, Redo ctrl + r
, repeat.
11. Smart Tips ctrl + n
orctrl + p
12. Delete motion
the crossed characters, delete and enter insert modec{motion}
13. Delete the character that crosses the next character, delete and enter insert mode, not including the x
characterctx
14. Remove all characters from the current character to the next character and enter insert mode, including x
characters,cfx
15. Delete motion
the crossed characters, delete but do not enter insert moded{motion}
16. Delete motion
the crossed characters, delete but do not enter insert mode, do not include x
charactersdtx
17. Remove all characters from the current character to the next character, including the x
characterdfx
18, if it is only a copy of the situation, the 12-17
article c
or d
change toy
19, delete to the end of the line can be used D
orC
20. Copy the current line yy
orY
21. Delete the current characterx
22. Pastep
23, you can use the multi-shear board, check the status :reg
of use, using ”
the Clipboard, such as copy to w
Register, ”wyy
or use the visual modev”wy
24. Repeated execution of the previous function using.
25, use the number can cross n
a region, for example y3x
, will copy the cursor to the third x
area between, 3j
moving down the 3
row
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
move to the definition of the function or variable where the cursor is located
30. K
man
Search for the word in the cursor
31, merging two linesJ
32. If you do not want to save the file, and re-open:e!
33. If you want to open :e filename
a new file, then use ctrl + ^
the file switch
Window operations
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 the current window only:only
6. To the left windowctrl + w,h
7, to the right windowctrl + w,l
8. To the top windowctrl + w,k
9. To the bottom windowctrl + w,j
10, to the top of the windowctrl + w,t
11, the bottom of the windowctrl + w,b
Macro actions
1. Start recording macro Operation q[a-z]
, press q
end, save operation to register [a-z]
2. @[a-z]
perform [a-z]
the operation in the Register
3. @@
perform macro operation of last record
Visual action
1. Enter the block visual modectrl + v
2. Enter the character visual modev
3, enter the line visual modeV
4. Delete the selected blockd
5. Delete the selected block and enter insert modec
6. Insert the same character in the selected blockI<String>ESC
Skip to Declaration
1. [[
jump forward to the top of the grid first{
2. []
jump forward to the top of the grid first}
3. ]]
jump back to the top of the grid first{
4. ]]
jump back to the top of the grid first}
5. [{
jump to the beginning of this code block
6. ]}
Skip to the end of this code block
Suspend operation
1. Suspend Vim ctrl + z
or:suspend
2. View tasks, shell
enter injobs
3, restore the task fg [job number]
(the background program to the front desk) or (Put the bg [job number]
foreground program in the background)
4. Execution of shell
orders:!command
5. Open shell
:shell
the command and exit theshell exit
6. Save vim
Status:mksession name.vim
7. Recovery vim
Status:source name.vim
8. vim
Recovery status at startupvim -S name.vim
A map of the keys, study hard.
VIM shortcut Key Finishing