vim使用笔记及资料收藏

vim使用笔记

********************************************************************************

----1----一般模式下按shift+Z+Z,相当于:wq

********************************************************************************

----2----VIM实现插入递增数字

比如想将第11行至17行的a修改成a1,a2,a3.可以这样子做

: let i = 1 | 11,17g/\<a\>/s//\=i/ | let i+=1

:help :g  可以查看g命令的帮助

:[range]g[lobal]/{pattern}/[cmd]       ()

            Execute the Ex command [cmd] (default ":p") on the
            lines within [range] where {pattern} matches.
h: :s
:[range]s[ubstitute]/{pattern}/{string}/[flags] [count]
            For each line in [range] replace a match of {pattern}
            with {string}.
When the {string} starts with "\=" it is evaluated as an expression, see
|sub-replace-expression|.  You can use that for any special characters.

在执行一次查找操作后,Vim会记住本次所使用的模式(pattern)和偏移量(±nlines)。下一次使用时,只需要指定查找的方向(和/或新的偏移量)即可。

h: :/
    /{pattern}[/]    the next line where {pattern} matches      *:/*

    \/        the next line where the previously used search
            pattern matches
/{pattern}    正向查找指定模式pattern
/    使用上一次模式和偏移模式进行正向查找,即当匹配模式为空时,表示以上一次匹配成功的模式
:[range]s[ubstitute]/{pattern}/{string}/[flags] [count]
            For each line in [range] replace a match of {pattern}
            with {string}.
When the {string} starts with "\=" it is evaluated as an expression, see
|sub-replace-expression|.  You can use that for any special characters.

在执行一次查找操作后,Vim会记住本次所使用的模式(pattern)和偏移量(±nlines)。下一次使用时,只需要指定查找的方向(和/或新的偏移量)即可。

h: :/
    /{pattern}[/]    the next line where {pattern} matches      *:/*

    \/        the next line where the previously used search
            pattern matches
/{pattern}    正向查找指定模式pattern
/    使用上一次模式和偏移模式进行正向查找,即当匹配模式为空时,表示以上一次匹配成功的模式
:[range]s[ubstitute]/{pattern}/{string}/[flags] [count]
            For each line in [range] replace a match of {pattern}
            with {string}.
When the {string} starts with "\=" it is evaluated as an expression, see
|sub-replace-expression|.  You can use that for any special characters.

********************************************************************************

----3----VIM在.c文件跳转到头文件,打开相应的头文件

光标移到头文件上:

gf

便可以打开相应的头文件了

ctrl+o

便返回到.c文件

********************************************************************************

----4----、VIM多标签切换

:tabnew [++opt选项] [+cmd] 文件            建立对指定文件新的tab
:tabc       关闭当前的tab
:tabo       关闭所有其他的tab
标准模式下:
gt , gT 可以直接在各个tab之间切换。

********************************************************************************

----4----vim多窗口
:new默认就是打开一个水平分割的新窗口。另外一个命令就是:split

垂直分割了,命令是:vsplit
直接连续按两次ctrl+w组合键,vim会自动跳到下一个窗口
或者通过组合键ctrl+w,然后通过j/k,来定位窗口

********************************************************************************

将多个空格替换成一个空格

正则表达式中:* 表示 匹配0或多个正好在它之前的那个字符

:%s/ * / /g


********************************************************************************

********************************************************************************

********************************************************************************

********************************************************************************

********************************************************************************

********************************************************************************

********************************************************************************

********************************************************************************

********************************************************************************

********************************************************************************

********************************************************************************

********************************************************************************

********************************************************************************

********************************************************************************

********************************************************************************

********************************************************************************

********************************************************************************

********************************************************************************

********************************************************************************

********************************************************************************

********************************************************************************

********************************************************************************

********************************************************************************






********************************************************************************

资料收藏


vimrc配置文件的编写

vim中一些高级替换技巧

vim 中替换命令的技巧汇总


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值