How to store grep results in a buffer in Vim?

Viewed 10233

I want to debug a process, hence I attached strace to the process and redirected the output to a file and then performed the operation. During the process it has created a lot of processes. So here is what I want to do, I want to select all the system calls executed by a process. To do that I used grep command with pattern as pid:

:grep pid %

It shows the result but I am not able to traverse through the result, it promts

Press ENTER or type command to continue

and returns to the file. What I would like to do is store the result in a buffer and then have a look into it and if required save it into a file or else discard it and return to the original file. Is there a way to do this with out exiting from the vim editor? Thanks in advance.

I would like to search with the result and store that in a buffer.

4 Answers

@romainl 's answer on how grep results into separate buffer or split window gives a much cleaner answer than quickfix/location lists.

:vnew | 0r!grep foo #
:tabe | 0r!grep foo #

but Quickfix lists are sort of intended for what you are doing but not the way you are doing it; however, it's tedious to set up unless it's a recurrent task.

Related