以下内容来自有关快速修复列表和位置列表的文档。但我不确定到底有什么不同。下图显示了位置列表和快速修复列表中的相同内容。我什么时候在 vimgrep 和 lvmgrep 中使用其中一个或另一个。
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.
...
更新
我发现了以下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.
所以区别在于快速修复列表的所有窗口和位置列表的本地窗口。不过,我可以从任何其他窗口打开位置列表。那么有什么区别呢??
最佳答案
位置列表是当前窗口的本地列表,因此您可以拥有与窗口一样多的位置列表:30 个窗口?没问题,这是您的 30 个并发位置列表。
快速修复列表是全局的,因此一次不能有多个可用。有些命令允许您将当前的快速修复列表替换为前一个快速修复列表,但不能有两个并发的快速修复列表。
不要将location/quickfix“列表”(数据结构)与location/quickfix“窗口”(显示这些数据结构内容的窗口)混淆。 “窗口”具有类似的行为,但“列表”则不然。区别很重要,因为幸运的是,这些窗口并不是与这些列表交互的唯一方式:有许多命令允许我们在这些列表中移动,而无需打开关联的窗口并了解这些列表之间的区别是有效使用这些命令的关键。
动手举例:
在
foo.txt
中执行:lvim foo %
为包含foo.txt
的窗口创建位置列表。执行几次
:lne
即可跳转到foo.txt
中的几个foo
。关注
bar.txt
并执行:lne
。会发生什么?现在,在
bar.txt
中执行:lvim bar %
为包含bar.txt
的窗口创建位置列表.执行
:lne
几次。你会跳到哪些比赛?在哪个缓冲区?在哪个窗口?切换到另一个窗口并执行
:lne
几次。会发生什么?再次切换到
bar.txt
。:lne
的作用是什么?现在,在
bar.txt
中执行:vim bar %
来创建快速修复列表。执行几次
:cn
可以跳转到bar.txt
中的几个bar
。现在,关注
foo.txt
,:cn
做什么?
结论:使用 :lne
跳转到的位置取决于您所在的窗口,这使得位置列表本地于窗口,但使用 :cn
跳转到的错误不是,这使得快速修复列表全局。
在我看来,这两个列表都有相对明确的作用:快速修复列表(以及快速修复窗口)通常在逻辑上专门用于错误,而位置列表(对我来说)似乎适合搜索。
关于vim - vim中的位置列表和quickfix列表有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20933836/