一直觉得 Vim 按键不好记,直到最近系统的学了一遍,按增(add)、删(delete)、改(update)、查找(find)、移动光标(navigate)、滚动(scroll)、生产效率(productivity)、其它(other)分类记忆,才感觉舒坦了。
add
- basic
a append
A append at the end of the line
i insert
I insert at the beginning of the line
- line
o append a new line
O insert a new line before the current line
delete
- basic
x delete a character
X delete the character before the cursor
D delete to the end of the line
- combo
d? delete ?
dd delete the current line
di? delete inner contents, for example: di>
da? delete whole group
update
- basic
s substitute a character
C change to the end of the current line
- combo
c? change ?
cc change the current line
r replace (overwrite) a character
find
- in line
f? find forward in the current line
F? find backward
- in file
* find the word under cursor
% find matching bracket: ( ), [ ] or { }
/ search forward
? search backward
n find next
N find previous
[Tab goto defination
navigate
- direction
h left
j down
k up
l right
- by word
w next beginning
e next end
b previous beginning
- in line
0 beginning
$ end
_ first non-blank character
- in file
gg beginning
G end
:10 goto line 10
- in screen
H highest
M middle
L lowest
- history
C-o jump to last cursor position (ctrl-o)
C-i jump to next (ctrl-i)
- bookmark
m? create a bookmark and assign a key to it
`? goto a bookmark
scroll
- by line
C-y line down (ctrl-y)
C-e line up (ctrl-e)
- by page
C-f page down (ctrl-f)
C-b page up (ctrl-b)
- locked
zz scroll the line with the cursor to the center of the screen
zt scroll the line with the cursor to the top
zb scroll the line with the cursor to the bottom
productivity
- select
v select
V select rows
C-v select block (ctrl-v)
- copy
y? yank
yy yank the current line
- paste
p paste after
P paste before
- undo/redo
u undo
C-r redo (ctrl-r)
- replace
:s/old/new replace in the current line
:s/old/new/g replace all in the current line
:10,20s/old/new/g replace all in between line 10 and 20
:%s/old/new/g replace all in the file
:%s/old/new/gc replace all in the file with confirmation
- indent
>> indent the current line
<< unindent the current line
>iB indent in-block code
<iB unindent in-block code
== reindent the current line
=% reindent block
- macro
q? start recording a macro and assign a key to it
q stop recording
@? playback a macro
@@ replay previously played macro
- misc
. repeat last command
10x remove 1 character, repeat 10 times
C-n auto-complete (ctrl-n)
~ invert the case of selected text
J join the next line
other
- quit
:q quit
:wq write and quit
:q! quit without saving changes
- tab
:tabe open file in a new tab
:tabn next tab
:tabp previous tab
- regex
in regular expressions you must backslash the character +
\v reduce backslashing
- misc
:e new
:o open
:w write
C-z goto console (ctrl-z)
C-g show current status (ctrl-g)
:! ? execute an external command
:h ? get help info about ?
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。