将下列文本内容复制到你的文件中,用vim打开
Welcome to to the world of of vim.
Practice makes a perfect.
A contented mind is the greatest blessing an man can enjoy in this world.
Will, work annd wait aree the pyramidal cornerstones for succcess.
使用本节学习命令修改以上有错误的句子
体会撤销与撤销撤销指令
体会删除命令
lesson3(粘贴、复制、替换)
命令总结
命令
功能
p
将之前删除掉的文本复制出来(针对于所有删除命令)
y+motion
复制所选字符,如yw,复制一个单词
r+char
char指任意字符,该命令将替换光标所指字符为char
ce+word
word指修改单词部分,该命令将替换光标之后单词的所有部分,并进入插入模式
c+num+motion
num为数字,motion为命令,如,c2w,删除两个单词,并进入插入模式
命令练习
将下列文本内容复制到你的文件中,用vim打开
The greater a mer is, the more disterreful is prrer and flatrer to him.
The greater a man is, the more distasteful is praise and flattery to him.
使用替换命令,将第一句改为第二句
使用删除命令,使用粘贴、复制命令
lesson4(文件、搜索、匹配)
命令总结
命令
功能
ctrl+g
在文件底部,显示文件路径、状态
G
到文件末尾
gg
回到文件开头
num+G
到文件num行
:/char
char是要查询的字符,向后查询
:?char
char是要查询的字符,向前查询
n
有多个匹配项时,可以逐次查找
N
与相同,但查找方向相反
%+括号
查询对应的另一个括号
:/s/old/new
将改行第一个old替换为new
: s/old/new/g
将该行所有old替换为new
:%s/old/new/g
将整个文件中的old替换为new
lesson5(执行外部命令、保存文件)
命令总结
命令
功能
:!+命令
如:!ls,将会显示列表
:w+filename
将文件保存
v
进入视图模式,选中的文本将会显示为高亮
vim超棒的命令
:set title ,vim可以查看当前打开文件所在目录及所在文件名,用ctags索引后,经常会使用