A small game to practice vim keys: http://vim-adventures.com/
Common keys in " Normal Mode " |
|
h |
left |
J |
down |
K |
Improvement |
l |
To the right |
20h |
20 characters to the left |
20j |
20 lines down |
20k |
20 lines of improvement |
20l |
20 characters to the right |
Page Up |
page up |
Page Down |
page down |
Home |
Move the cursor to the far left of the current line |
End |
Move the cursor to the far right end of the current flight |
n [ space ] |
Move the cursor n characters to the right |
N[Enter] |
Cursor down N lines |
G |
Move the cursor to the last line |
nG |
Move the cursor to the nth line |
gg or 1G |
Move the cursor to the first line |
/word |
look down word |
?word |
look up word |
n |
If it is used after /word , it means to continue searching downwards; If it is used after ?word , it means to continue searching upwards; |
N |
如果是/word后使用,则表示向上继续查找; 如果是?word后使用,则表示向下继续查找; |
:n,m/old/new/g |
从第n行到第m行中,将old替换为new |
:n,$s/old/new/g |
从第n行到最后一行中,将old替换为new |
u |
类似windows中的CTRL+Z,前一步 |
x |
向后删除一个字符 |
X |
向前删除一个字符 |
3x |
向后删除3个字符 |
3X |
向前删除3个字符 |
dd |
删除当前行 |
3dd |
删除当前行开始的3行 |
yy |
复制当前行 |
3yy |
复制当前行开始的3行 |
p |
黏贴到当前光标的下一行 |
P |
黏贴到当前光标的上一行 |
CTRL+r |
重做前一个操作 |
. |
重复前一个操作 |
“命令行模式”的常用按键 |
|
:w |
保存 |
:q |
退出vim |
:wq |
保存并退出 |
:wq! |
(在可以转换权限的情况下)强制保存并退出 |
:q! |
直接退出不保存 |
:w filename |
另存为filename |
:n,m w filename |
将第n行到第m行另存为filename |
:set nu |
显示行号 |
:set nonu |
不显示行号 |
:! command |
暂时离开vim,并执行command,执行完后再进入vim |
:r filename |
将filename文件的数据读入当前文件 |
:set all |
显示当前vim的环境配置 |
set hlsearch |