刪除
: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