2

I have a location list populated with around 50 lines, and I would like to remove some of these. Is there a way?

Specifically, I searched for references of a Java method and the LSP (using coc-java) filled the references, but most are to test classes, which do not interest me at the moment.

3 Answers 3

3

Recent vim version has a builtin package cfilter for this.

:packadd cfilter
:Lfilter! /pattern-to-delete/

This will remove all lines in location list (or Quickfix list if CFilter is used) that matches the pattern

See :help CFilter

2

There's no builtin command, so you need to do a bit of scripting. Sort of this

:call getloclist(0)->filter('v:val.text !~? "test"')->setloclist(0)

Alternatively, you may want to search through github for relevant plugins, e.g. github.com/search topic:vim topic:quickfix or github.com/search topic:vim topic:quickfix-window and so on.

1

Is the loclist coming from the result of running :make ? If so, then you can add to the errorformat setting using %-G<pattern> to ignore all error lines matching <pattern>.

The errorformat setting may be a result of your filetype and the :compile <compiler> command. There is a compiler file $VIMRUNTIME/compiler/javac.vim which you might be using. That file sets errorformat like this:

CompilerSet errorformat=%E%f:%l:\ %m,%-Z%p^,%-C%.%#,%-G%.%#

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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