代码: 全选
basic:
↑
← h j k l →
↓
:w write / save
:w {file} write to file / save as
:wq / ZZ write and quit / save and quit
:q! / ZQ force quit / quit without saving
d{motion} delete / cut
y{motion} yank / copy
p put / paste
cursor -> line:
a append after the cursor
A append after the line
i insert before the cursor
I insert before the line
r replace at the cursor
R replace the line
s substitute at the cursor
S substitute the line
u undo CTRL-R undo the undo
U undo the line
v start visual mode per character
V start visual mode line-wise
forward -> backward:
x delete characters forward
X delete characters backward
p put after the cursor
P put before the cursor
o open a line below
O open a line above
f{char} find {char} forward
F{char} find {char} backward
t{char} till {char} forward
T{char} till {char} backward
; next {char} occurrence
, previous {char} occurrence
/{pattern} search {pattern} forward
?{pattern} search {pattern} backward
n next {pattern} occurrence
N previous {pattern} occurrence
motion / word -> WORD:
w forward to the start of word
W forward to the start of WORD
e forward to the end of word
E forward to the end of WORD
b backward to the start of word
B backward to the start of WORD
ge backward to the end of word
gE backward to the end of WORD
0 to the first character of the line
^ to the first non-blank character of the line
$ to the last character of the line
g_ to the last non-blank character of the line
d -> dd -> D:
d{motion} delete
dd delete a line
D delete to the end of the line
c{motion} change
cc change a line
C change to the end of the line
y{motion} yank/copy
yy yank/copy a line
Y same as yy, unfortunately we are not in a perfect world
advanced:
H High / to first line on the window
M Middle / to middle line of the window
L Low / to last line on the window
:1 / gg to first line of the file
:[+/-]{number} to relative/absolute line number
:$ / G to last line of the file
% find a matching
:s/old/new substitute once
:s/old/new/g substitute all on a line
:%s/old/new/g substitute all in the file
:%s/old/new/gi substitute all in the file, ignore case
:%s/old/new/gn count occurrence only, do not substitute
:%s/old/new/gc substitute all in the file, with confirmation
:!{cmd} execute {cmd} with the shell
:!! repeat last shell command
:w !sudo tee % save as root