Last Updated: February 25, 2016
·
900
· sajnikanth

vim: Search, copy and paste to another file

First open the file, in which you want to search. At the prompt:

:vimgrep /<pattern>/ %

Display just the selected lines:

:copen

Yank all lines

:%y

Open another file within vim:

:e ~/my_results.log

Paste all the yanked lines here:

:p