Samselvaprabu
Samselvaprabu

Reputation: 18147

How to search a pattern in between a string and show it in quick fix?

In my log file some times there will be many errors. I will filter the errors between the lines and will see the files which are executed in between.

So in short I will search a pattern between ranges.

1000,2000g/.yaml:/#

now this result is display in screen. But I want it to be in quickfix so that I can select different lines till I complete. How to push this result into quickfix window?

Upvotes: 0

Views: 189

Answers (1)

Kent
Kent

Reputation: 195059

you can use the :cadde command together with your g command. There is a nice example in the help doc to show how it works:

:g/mypattern/caddexpr expand("%") . ":" . line(".") .  ":" . getline(".")

In your case, you just need to add the range and change the pattern. please check the doc for details:

:h cadde

After you put things into quickfix list, I've written a little plugin several years ago to allow you to do further filtering (multiple levels and undo-able) in the quickfix:

https://github.com/sk1418/QFGrep

Upvotes: 0

Related Questions