VIM操作速查
作者:互联网
vim下的模式
insert模式、normal模式、visual模式、command模式
-
进入insert
a/i/o、A/I/O;a【append】、i【insert】、o【在下一行插入】;
-
进入normal
esc。默认模式就是normal
-
进入visual
v,V【选择行】,ctrl+v【进行方块选择】
-
进入command
按【:】
【:wq】保存退出
分屏
【:vs】vertical split 【:sp】split
替换
% s/php/go/g 全局替换;%表示全部文件,s执行替换,g表示全局
insert模式小技巧
- ctrl+h删除光标前一字符
- ctrl+w删除光标前一单词
- ctrl+u删除光标前的一行
终端命令行小技巧
- ctrl+h删除光标前一字符
- ctrl+w删除光标前一单词
- ctrl+u删除光标前的一行
- ctrl+a光标到命令开头
- ctrl+e光标到命令结尾
- ctrl+b光标前移
- ctrl+f光标后移
normal模式小技巧
-
gi 快速切换到上次insert模式下的编辑位置
-
hjkl移动。最常用的是下移,所以右手食指是j下移
-
w/W移到下一个word/WORD开头
-
e/E下一个word/WORD尾
-
b/B到上一个word/WORD开头,b->backword
word指以非空白符分割的单词,WORD以空白符分割的单词
移动
行间搜索移动
-
f+char :char->你要搜索的字母/字符
-
F+char :反过来从行尾向行首搜索字符,当光标在行尾时需要
-
t移动到char的前一个字符
如果第一次没搜索到,可以用【;】和【,】进行上一个/下一个切换
快速到行首行尾
-
0移动到行首第一个字符,移动到第一个非空白字符(0+w也可以实现功能)
-
$移动到行尾,g_移动到行尾非空白字符
其实常用的的记住0和$就可以
垂直移动
- 使用 ( ) 在句子之间移动,使用 { } 在段落之间移动
- 也可使用easy-motion插件移动,使用这个插件这些命令就不用记忆啦
页面移动
- gg/G移动到文件的开头和结尾,可以使用ctrl+o快速返回上一个位置
- H/M/L跳转到开头、中间、结尾
- ctrl+u、ctrl+f上下翻页、zz把屏幕置为中间
可以用:help来查看帮助。比如 使用 :help ( 就可以查看(的帮助说明了
删
- x删除一个字符,可搭配数字多次执行
- d删除一个单词,可搭配数字多次执行
- dd:删除一整行
- d$:删除到行尾
- d0:删除到行首
- dt):delete to );也可以dt"、dt>等等
- dw(diw的简写)、diw、daw。根据范围文本对象删
范围文本对象
iw(inside the word)当前单词、aw(around the word)当前单词及空格
改
r(replace)、c(change)、s(substitute)
- r+char:替换字符
- s:删除当前字符并进入插入模式
- R+char1、char2、char3:相当于多个r的操作连续起来
- S:整行删除,并进入插入模式
- c可以配合文本对象,删除并进入插入模式
- cw、caw、ct"
- C删除整行来进行插入操作
查
/、?、n、N、*、#
set hls(high light search)
set incsearch (一边搜索一边高亮)
搜索替换
标签:字符,删除,ctrl,模式,VIM,操作,速查,移动,光标 来源: https://www.cnblogs.com/abzor/p/15304168.html