References#
Modes#
- Normal Mode:
ESC
- Insert Mode:
i
- Replace Mode:
R
- Visual Mode:
v
- Command Mode:
:
Commands#
- Quit:
:q
- Save:
:w
- Save and quit:
:wq
- Quit without save:
:q!
- Open file for editing:
:e {filename}
- Show open buffers:
:ls
- 切换不同buffer:
:b {filename}
- 关闭当前buffer:
:bw
- Help:
:help {topic}
- opens help for the
:w
command: :help :w
- opens help for the
w
movement: :help w
- jump from one window to another:
Ctrl-W
+Ctrl-w
- Shell command:
:!
- Retrieve from file:
:r {filename}
- Retrieve from command:
:r !ls
- Set option:
:set {option}
- Ignore case:
:set ic
- 关掉选项,前面加’no’:
:set noic
- Highlight search:
:set hls
/:nohlsearch
- 清除上次搜索结果:
:noh
- Command completion:
Ctrl-D
, or TAB
Normal mode#
Movement#
- Basic movement:
hjkl
(left, down, up, right)
- Words:
w
(next word)
b
(beginning of word)
e
(end of word)
- Lines:
0
(beginning of line)
^
(first non-blank character)
$
(end of line)
- Screen:
H
(top of screen)
M
(middle of screen)
L
(bottom of screen)
- Scroll:
Ctrl-U
(up)/Ctrl-D
(down):Scroll half a page
Ctrl-B
(up)/Ctrl-F
(down):Scroll a page
- Percentage jump
- File:
gg
(beginning of file)
G
(end of file)
- Line numbers:
- Find:
f{character}
, t{character}
, F{character}
, T{character}
- find/to forward/backward {character} on the current line
,
/ ;
for navigating matches
- Search: `/{regex}``
n
/ N
for navigating matches
?
: search in backward direction
/ignore\c
: ignore case
- 跳到对应括号:
%
(corresponding item)
Edits#
- insert:
i
: insert
a
: append
A
: append at the end of line
- insert line below / above:
o
/O
- delete:
d{motion}
dw
: delete word
d$
/D
: delete to end of line
d0
: delete to beginning of line
dd
: delete line
- change:
c{motion}
- delete character:
x
- substitude character:
s
:s/old/new/
: substitute ’new’ for the first ‘old’
:s/old/new/g
: substitute ’new’ for ‘old’ globally in the line
:s/old/new/gc
: with prompt
:5,10s/old/new/g
- replace character:
r
- undo:
u
- redo:
Ctrl-R
- copy (yank):
y
- paste:
p
- filp the case:
~
- code complete
Ctrl-N
: Forward
Ctrl-P
: Backward
Counts#
3w
move 3 words forward
5j
move 5 lines down
7dw
/d7w
delete 7 words
Misc#
Visual Mode#
- Visual:
v
- Visual Line:
V
- Visual Block:
Ctrl-V
- Insert in Visual Mode:
Shift-I
Windows#
- Split window:
:sp
/:vsp
:sp {filename}
: split window with file
Ctrl-W
+s
/ Ctrl-W
+v
- Move left/down/up/right:
Ctrl-W
+h
/j
/k
/l
,
- Move to next window:
Ctrl-W
+w
Plugins#
ctrlp.vim#
NERDTree#