1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
| vim <filename> # Open <filename> in vim
:help <topic> # Open up built-in help docs about <topic> if any exists
crtl+d,tab # list completing command, completing command
crtl-w [h,j,k,l] # switch from window
:split,:vsplit [fn] # split
crtl-w [H,J,K,L] # move window
crtl-w [=,<,>,-,+] # adjust window size
:omly # close other window
i,a,A,o,O # 插入模式,cursor前,后,句子末尾,下一行,上一行
d[w,0,$],c[w,0,$] # delete,delete and inset | 光标左边至下个单词,行首,行末
[NUM]dd # 删除几行
p,P # paste register after,before cursor, for a line after,before current line
r[x],R[x...] # replace the word of cursor with 'x', replace multiple
:q # Quit vim
:w # Save current file
:wq # Save file and quit vim
:q! # Quit vim without saving file
:! [command] # exec external shell command
u,U,crtl+r # undo one,all actions;redo one action
hjkl # 移动
[NUM]+b,w,e # 移动到前NUM个单词,后NUM个单词,后NUM个单词最后字符
0,^,$ # 每行-开始,非空,最后字符
gg,[NUM]G,:NUM # goto文件首行,[NUM行]或文件末行,指定行数
crtl+o,crtl+i # jump forward or downward
crtl+g # show file status
% # jump between paired ()[]{}
H,M,L # goto屏幕首行,屏幕中间,屏幕末行
crtl+u,crtl+d # scroll between screen
?word,/word # Highlights all occurrences of word before,after cursor
N,n # Moves before,after search
:%s/foo/bar/g # Change 'foo' to 'bar' on the file,没有g只会替换每行的第一个
:s/foo/bar/g # Change 'foo' to 'bar' on the current line
:'<,'>s/foo/bar/g # Change 'foo' to 'bar on every line in the current visual selection
:[#,#]s/foo/bar/gc # change for line # to # and prompt whether to delete
f< # Jump forward and land on < in a line
t< # Jump forward and land right before < in a line
|