Dskpimc? · 2020年09月04日

gvim常用操作整理

效率,效率,效率!!!

首先说下vi、vim、gvim的关系,vi是Linux OS的文本编辑器,vim是vi improced,gvim是GUI of vi。gvim支持两种模式:editing and command mode。还有.vim是gvim的highlight word file,.vimrc是configuration file of VI。vi和vim打开和编辑文件都是在terminal上进行,gvim会打开GUI界面进行编辑,不占用terminal,更方便处理文件。

基本命令:

:i →go to editing mode
esc→go to command mode
:w→write into the file(save)
:q→quit vi
:q!→force to quit and abort the modification
:wq→save and quit

移动光标命令:

h|j|k|l:h(left)|j(down)|k(up)|l(right)
:w→move forward one word , 前面加n,即nw移动n word
:b→move backward one word, 前面加n,即nb移动n word
:$→move to the end of a line
:^→move to the beginning of a line
:gg→go to the first line
:G→go to the last line
:nG→go to the n line, 使用n+gg也可以达到目的
:set nu:set number line
:set nonu
CTRL+G:display the total number of lines
CTRL+U:page up
CTRL+D:page down

删除、复制、粘贴 :

d=delete, y=copy, p=paste
dd:delete a line   eg. 5dd
dw: delete a word eg. d3w
d0:delete to begin of line
d$:delete to end of line
yy:copy a line et. 5yy
yw:copy a word
y0:copy to begin of line
y$:copy to end of line
Y:copy a line
:5,10y      :copy 5 ~ 10 line
:,10y        : copy cursor ~ 10 line
:5,y          :copy 5 ~ cursor line
:p:paste
:.        : rpeat last operation
:x        : delete a character eg. 3x

撤销编辑:

:u|U      : undo | redo(好像不行)
:CTRL+R   : need the modification,和u有点相反的意思

插入光标:

:a|A       : a is enter the cursor after the current character,A is enter the cursor after the end of a line
:i|I          : i is enter the cursor before the current character,A is enter the cursor before the begin of a line
:o|O       : o is input one new line under the current line,O is input one new line up the current line

查询:

:/pattern : go to the pattern
          : n|N
:?pattern :go to the pattern
          : n|N
SHIFT + * : match the word marked cursor
:number_line : go to the number line

gg
gd:select current word
gf:go to current file path

替换:

:r|R          : replace
:%s/x/y/g     : x change to y all of them
:s/x/y/g        : x change to y on the current line
:n,ms/x/y/g   :x change to y on the n to m line

特别操作:

:sp       : splite horizontally ; put some files into one terminal
:vsp      : visual splite vertically
CRTL + WW : change file in split command,在file之间跳转
:q   or  ZZ  : quit a splite file
CRTL + V  : visual mode
SHIFT + i   : insert mode for editing
SHIFT + a  : insert mode for editing
ESC       :Mactch visual mode
CRTL + O  : return the original file
J        :Merge the under line and the current line eg. 3J
~        :change case-sensitive character

相关阅读

AXI协议之读写命令保序
AMBA APB总线

作者:谷公子
首发博客:https://blog.csdn.net/W1Z1Q/article/details/100068720
2 阅读 209
推荐阅读
0 条评论
关注数
1789
内容数
255
主要交流IC以及SoC设计流程相关的技术和知识
目录
极术微信服务号
关注极术微信号
实时接收点赞提醒和评论通知
Arm中国学堂公众号
关注Arm中国学堂
实时获取免费 Arm 教学资源信息
Arm中国招聘公众号
关注Arm中国招聘
实时获取 Arm 中国职位信息