| 键位 | 功能 |
|---|---|
| h、j、k、l | 左、下、上、右 |
| i、Esc | 命令→输入,输入→命令 |
| x | 删除后一个字符(delete) |
| X | 删除前一个字符(backspace) |
| u | 撤销上一次动作(vi) |
| CTRL-R | 无限次撤销上一次动作(vim 限定) |
| 0、$、^ | 跳到行首、跳到行尾、跳到非空行首 |
| b、w、e | pre word、next word、end word(word 传统单词) |
| B、W、E | pre WORD、next WORD、end WORD(WORD 是非空字符的序列) |
| R | 进入取代模式(Replace mode) |
光标移动
f + key,find key,移动到本行下一个 key 的位置
F + key,find key,移动到本行上一个 key 的位置
t + key,till key,移动到本行下一个 key 的位置,光标在 key 右侧
T + key,till key,移动到本行上一个 key 的位置,光标在 key 右侧
删除操作
d + motion,delete motion,删除当前光标到 motion 位置的文本
c + motion,change motion,删除当前光标到 motion 位置的文本,并进入插入模式
#
dw # 删除当前 word
dfi # 删除到下一个 i 位置
dj # 删除该行
dk # 删除上一行
dd / cc # 删除当前行2i # 重复文本,after press Esc to finish input sessions
v # vim 中,进入 visual mode,move around with motions,the text will be highlighted。press an operator to operate on that selections。
V # 进入 visual-lines mode - like v,but selecting whole lines。
ctrl-v # selects rectangular blocks
在 motion 前,增加数字代表重复多次。
d2w # 删除到 second word
d2j # 删除下 2 行
command/operator - yank & paste
y + motion,yank/copy 到 motion 的光标处
p,paste after(if charwise, to the right, if linewise, below)
P, paste before.
yy, copy the current line.
y, also works in visual mode.
Text deleted with d, c, x … is also copied.

search motion
/text, search the text, and then press return.
?text, does the same, but backwards.
n, repeats the last search in the same direction.
N, repeats it in reverse direction.
Be careful, text is regular text, so a*b means zero or more a’s followed by b.
*, only in vim, searches forward for the next instance of the identifier under the cursor.
#, only in vim, does the same backwards.