软讯网络 > 操作系统 > Linux > vim中把用正则表达式匹配的字符串写到一个新文件的方法
【标 题】:vim中把用正则表达式匹配的字符串写到一个新文件的方法
【关键字】:
vim
【来 源】:http://www.cublog.cn/u/24274/showart.php?id=177303
vim中把用正则表达式匹配的字符串写到一个新文件的方法

redirect selected parts to a new file
1: :g/patten/y A Append to the
contents of the register if its name is given
uppercase {A-Z}
create a file in vim
"ap
2:delete unwanted lines
:g/^[^0-9]\+\n/d
3: :redir >> tmp
:g/^\d\+/p
:redir END
"send output of previous global command to a new window
:nmap <F5> :redir @a<CR>:g//<CR>:redir END<CR>:new<CR>:put! a<CR><CR>