如何从vim命令行中选择?

时间:2014-01-24 07:03:18

标签: vim

我正在尝试找到一个模式并删除该块。

要删除阻止我手动执行V$%x

V - 行选择,$ - 移动到行尾(有一行{end of line),% - 移动到匹配},x - 删除块

我想知道有没有办法实现自动化。有全局命令:g但我不知道如何在命令模式下选择文本。

2 个答案:

答案 0 :(得分:6)

仅供记录,找到解决方案

编辑:

:g/pattern/norm! V$%x

答案 1 :(得分:0)

v激活视觉模式后,您可以选择:

aw  a word (with white space)           
iw  inner word                  
aW  a WORD (with white space)           
iW  inner WORD                  
as  a sentence (with white space)           
is  inner sentence                  
ap  a paragraph (with white space)          
ip  inner paragraph                 
ab  a () block (with parenthesis)           
ib  inner () block                  
aB  a {} block (with braces)            
iB  inner {} block                  
a<  a <> block (with <>)                
i<  inner <> block                  
a[  a [] block (with [])                
i[  inner [] block    

希望有所帮助