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

 

  • 1
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
GVim 是一个功能强大的文本编辑器,可以在终端中使用。下面是一些常用GVim 命令: 1. 打开文件: 在 GVim 中,你可以通过在终端输入 `gvim 文件名` 来打开一个文件。例如,`gvim test.txt` 将打开一个名为 test.txt 的文件。 2. 复制和粘贴: 在 GVim 中,你可以使用 `yy` 命令来复制当前行,并使用 `p` 命令来粘贴在光标位置。例如,将光标放在想要复制的行上,然后按下 `yy`,接着将光标移动到希望粘贴的位置上,然后按下 `p` 来粘贴。 3. 保存和退出: 在 GVim 中,使用 `:w` 命令可以保存当前文件,使用 `:q` 命令可以退出 GVim。如果你在进行编辑时没有保存文件,GVim 会警告你保存文件。如果你想同时保存并退出,可以使用命令 `:wq`。 4. 搜索和替换: 在 GVim 中,你可以使用 `/关键词` 来搜索当前文件中的关键词。例如,如果你想搜索文件中的 "hello",只需在命令行中输入 `/hello`,按下 Enter 即可。你还可以使用 `:s/旧关键词/新关键词/g` 来替换文件中的内容。 5. 跳转和移动: 在 GVim 中,可以使用 `gg` 命令来跳转到文件的开头,使用 `G` 命令跳转到文件的结尾,使用 `:行号` 命令跳转到特定行。还可以使用 hjkl 键来在文件中上下左右移动光标。 6. 撤销和重做: 在 GVim 中,使用 `u` 命令可以撤销最后的操作,使用 `Ctrl + r` 命令可以重做。 这些是一些 GVim 常用的命令,希望对你有帮助!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

谷公子的藏经阁

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值