JUST DO IT ~

我只想当个程序员

vim 常用

删除

:g/.*ABC/m

:g/kernel32/d

:[range]g[lobal]/{pattern}/[cmd] :help :g

vim 查找一个文章段落, 开头字符 结尾字符

/.*#tag1\(.\+\n\+\)\{-}#tag2.*

 

删除掉 :

g/.*#tag1\(.\+\n\)\{-}#tag2.*/d

这句话\(.\+\n\+\) 采用分组

.\+  .任意字符 + 一个或多个

\n\+  回车  一个或多个

\+1 或更多

\{-} 0 或更多尽可能少. 任意字符

\n 换行符

为什么  /This\_.*text/ 不可以,因为\_. 是全缓冲区匹配模式的.

 

概念分组、捕获

http://i.linuxtoy.org/docs/guide/ch26s08.html#id3120909

abc123.456.def

\d{3}表示三个数字,(\d{3}\.)表示三个数字加“.”为一组,{2}表示这一组内容重复两次

 

 

 

参考:

http://vimcdoc.sourceforge.net/doc/pattern.html#search-pattern

^\(.\+\n\)\{-}#.*tag1

http://stackoverflow.com/questions/10076834/multi-line-regex-in-vim-filtering-out-blocks-of-text-in-a-file

Vim 中删除符合条件的行

http://timothyqiu.com/archives/delete-lines-matching-pattern-in-vim/ https://github.com/railsinstaller/railsinstaller-windows/releases

posted on 2014-06-25 14:24 小高 阅读(175) 评论(0)  编辑  收藏 所属分类: Linux


只有注册用户登录后才能发表评论。


网站导航:
 

导航

<2014年6月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

统计

常用链接

留言簿(3)

随笔分类(352)

收藏夹(19)

关注的blog

手册

搜索

积分与排名

最新评论

阅读排行榜

评论排行榜