当前位置:操作系统 > Unix/Linux >>

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>
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,