i 当前光标插入
I 当前光标的行首插入
a 当前光标后插入
A 当前光标的行尾插入
o 当前光标下一行插入
O 当前光标上一行插入
r 当前光标字符替换
w 下一个单词
b 上一个单词
[[ 下一个函数头
]] 上一个函数头
在ctags下
ctrl + ] 跳转到该函数
ctrl + t 回退跳转
ctrl + f 向下翻页
ctrl + b 向上翻页
ctrl + d 向下翻半页
ctrl + u 向上翻半页
vim -O file1 file2 纵向分屏
vim -o file1 file2 横向分屏
ctrl + w w 切换至下一个窗口
ctrl + w = 所有窗口等高等宽
:vs(vsp) 纵向增加分屏
:sp 横向增加分屏
:res num 当前窗口显示num行
:vertical res num 当前窗口显示num列
ctrl + n 自动补全
:%s/words1/words2/g 全局替换
替换当前行中的内容:
:s/from/to 将当前行中第一个from替换成to
:s/from/to/g 将当前行中所有from替换成to
:s/from/to/gc 将当前行中所有from替换成to,但每次替换之前都会询问请求用户确认此操作
替换某一行的内容:
:.s/from/to/g 将当前行中所有from替换成to
:33s/from/to/g 将33行中所有from替换成to
:$s/from/to/g 将最后一行中所有from替换成to
替换某些行的内容:
:10,20s/from/to/g 将10至20行中所有from替换成to
:1,$s/from/to/g 将1至最后一行中所有from替换成to
:1,.s/from/to/g 将1至当前行中所有from替换成to
u 撤销
ctrl + r 回退撤销
v 单个字符选中
V(shift + v) 行选中
ctrl + v 块选中
多行注释
ctrl + v 选中要注释的行,I插入,写//或#,连按两次Esc
多行取消注释
ctrl + v 选中要取消的行的注释符,d删除
d w 删除单词(光标在词首)
ctrl + s vim停止向终端输出
ctrl + q 退出ctrl + s状态
q: 查看历史命令
ctrl + g 显示文件信息,统计行号