The following is from the documentation about the quickfix list and location list. But I am not sure what actually different. The image below shows the same things from the location list and quickfix list. When do I use one or another in vimgrep and lvimgrep.
In Vim the quickfix commands are used more generally to find a list of positions in files.For example, |:vimgrep| finds pattern matches. You can use the positions in a script with the |getqflist()| function. Thus you can do a lot more than the edit/compile/fix cycle! ... ... *location-list* *E776* A location list is similar to a quickfix list and contains a list of positions in files. A location list is associated with a window and each window can have a separate location list. A location list can be associated with only one window. The location list is independent of the quickfix list. ...
UPDATE
I found the following from here.
These commands all fill a list with the results of their search. "grep" and "vimgrep" fill the "quickfix list", which can be opened with :cw or :copen, and is a list shared between ALL windows. "lgrep" and "lvimgrep" fill the "location list," which is local to the current window, and can be opened with :lw or :lopen. Both of these lists can be used to instantly jump to the matching line in whatever file it occurs in.
So the difference is all windows for quickfix list and local window for location list. However I can open location list from any other windows. So what is the difference then??
The quickfix and location lists provide a powerful way to navigate in Vim especially in the context of searching a file or project, and when inspecting errors. Essentially, they are lists of file locations with a built-in set of commands for navigating between them, and they can be populated in a variety of ways.
The location list is local to the current window so you can have as many location lists as windows: 30 windows? No problem, here are your 30 concurrent location lists.
The quickfix list is global so you can't have more than one available at a time. There are commands that allow you to replace the current quickfix list with a previous one but you can't have two concurrent quickfix lists.
Don't confuse the location/quickfix "lists" (the data structures) with the location/quickfix "windows" (the windows displaying the content of those data structures). The "windows" have similar behaviors but the "lists" don't. The difference is important because those windows are thankfully not the only ways to interact with those lists: there are many commands that allow us to move through those lists without opening the associated windows and knowing the difference between those lists is key to using those commands efficiently.
Hands-on illustrated example:
Do :lvim foo %
in foo.txt
to create a location list for the window containing foo.txt
.
Do :lne
a few times to jump to a few foo
in foo.txt
.
Focus on bar.txt
and do :lne
. What happens?
Now, do :lvim bar %
in bar.txt
to create a location list for the window containing bar.txt
.
Do :lne
a few times. What matches do you jump to? In which buffer? In which window?
Switch to the other window and do :lne
a few times. What happens?
Switch again to bar.txt
. What does :lne
do?
Now, do :vim bar %
in bar.txt
to create a quickfix list.
Do :cn
a few times to jump to a few bar
in bar.txt
.
Now, focus on foo.txt
, what does :cn
do?
Conclusion: the location you jump to with :lne
depends on the window you are in, which makes the location list local to a window, but the error you jump to with :cn
is not, which makes the quickfix list global.
Both lists have relatively clear roles IMO: the quickfix list (and thus the quickfix window) is usually and quite logically devoted to errors and the location list seems (to me) fit for search.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With