Vim 中位置列表和快速修复列表的区别是什么

下面是关于快速修复列表和位置列表的文档。但我不确定到底有什么不同。下面的图片显示了相同的东西从位置列表和快速修复列表。我什么时候在 vimgrep 和 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

更新

我找到了以下 从这里

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.

所以不同的是所有窗口的快速修复列表和本地窗口的位置列表。但是我可以从任何其他窗口打开位置列表。那有什么区别呢?

23476 次浏览

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.