8

There are several times, I need to grep for some_pattern in some XHTML files (many a time, file count in a specified folder goes beyond 10K+).

Previously, I have used Lugaru's Epsilon Programmer's Editor and there was grep command which invokes the search, and results a list of all matched lines in a grep-buffer. Afterwards, a user can use commands (like keep-matching-lines, delete-matching-lines, sort-lines, uniq etc.) on the grep-buffer. Since, the grep-buffer is editable, it is possible to post-process and mold the grep-result to desirable format as required.

But, that was weeks ago! This time, I have started to use Vim as my full-time editor. I am trying to quit all possible habits those are becoming obstacles to learning Vim. So, right now whenever I need to get such a search list, I am trying the same, in following way:

:cd d:\test_files\
:cex [] | vimgrep /pattern/ *.xhtml
:cope

Now, this servers my purpose well, except that the buffer remains in RO mode. So, every time it requires special post-editing process, I need to prepare a replica for the quickfix-window and then do as required. The quickfix-window is always uneditable.

Is there any way to make the quickfix-window editable? I know the result can be post-processed with some other commands in a single line, but I do need to view all the search list as whole and only then can I judge what the next steps should be.

Is there any tweak that can be applied in the vimrc? Am I missing something? Pointing out my error or any other approach to get job done, is greatly appreciated.

  • 4
    Have you tried :set modifiable? Alternatively, :redir could help. – fruglemonkey Feb 16 '16 at 15:02
  • @fruglemonkey: Thank you so much....That's what all i needed...you rocks!!!! – Cylian Feb 16 '16 at 17:17
  • 1
    Related post: Is it possible to grep Vimʼs quickfix? – Peter Rincker Feb 16 '16 at 18:03
  • Just got the new updated on Debian with patch: 8.1.0311. Works great! :) – Marcel Aug 25 '18 at 12:09
5

You definitively should try the plugin QFGrep plugin, which was created after the similar question mentioned in the comments: Is it possible to grep Vimʼs quickfix?.

I've been using it for a year and a half, and it works very well. It allows to grep (and reverse grep) the quickfix results, and also allows to restore the original contents. Check plugin homepage, which has a nice animated gif.

  • mMontu: must give it a try tomorrow....looks like what i really need.... – Cylian Feb 16 '16 at 20:05
  • It is a really cool script...thank you so much... – Cylian Feb 17 '16 at 7:04
2

New official vim plugin cfilter

Since 21.8.2018 (patch: 8.1.0311) the plugin cfilter is distributed with vim in $VIMRUNTIME. It is documented under :h cfilter-plugin.

Load plugin cfilter when needed or load it always in your vimrc

:packadd cfilter

Filter quickfix list with

:Cfilter DPUST

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.