1

I can customize some error display in my file like highlight all white space at the end of each line by:

:match ErrorMsg /\s\+$/

Can I put all the error I found into quickfix windows that I can go through it one by one?

1

You can use :vimgrep /pattern/ % to search the current file for pattern and put the results in the quickfix list.

There is also :grep which works in the same way but uses an external program to do the search.

You did not ask for it but in simple situations (like removing trailing spaces) you can also use the :substitute command. For example with

:%s/\s\+$//ec

you will be walked through every match in the file and can confirm if you want it removed. (e is to ignore errors like "no matches found" and c is for interactive confirming every replacement)

  • this will automatically jump to first error, can it just open quickfix but not jump to it? – How Chen Aug 3 '18 at 13:26
  • 1
    Yes it is in the docs I linked ;) use the j flag. You should always read the docs!! – Lucas Aug 3 '18 at 15:04
  • ah..sorry, use mobile to read and did not notice the link. Thanks again. – How Chen Aug 3 '18 at 15:07

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.