What is the difference between location list and quickfix list in vim

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.

...

enter image description here

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??


Solution 1:

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:

$ vim -O foo.txt bar.txt

  1. Do :lvim foo % in foo.txt to create a location list for the window containing foo.txt.

  2. Do :lne a few times to jump to a few foo in foo.txt.

  3. Focus on bar.txt and do :lne. What happens?

  4. Now, do :lvim bar % in bar.txt to create a location list for the window containing bar.txt.

  5. Do :lne a few times. What matches do you jump to? In which buffer? In which window?

  6. Switch to the other window and do :lne a few times. What happens?

  7. Switch again to bar.txt. What does :lne do?

  8. Now, do :vim bar % in bar.txt to create a quickfix list.

  9. Do :cn a few times to jump to a few bar in bar.txt.

  10. 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.