以下内容来自有关quickfix列表和位置列表的文档.但我不确定究竟有什么不同.下图显示了位置列表和quickfix列表中的相同内容.我什么时候在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.
...
Run Code Online (Sandbox Code Playgroud)
UPDATE
我从这里找到了以下内容.
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.
Run Code Online (Sandbox Code Playgroud)
所以区别在于所有用于quickfix列表的窗口和用于位置列表的本地窗口.但是我可以从任何其他窗口打开位置列表.那么有什么不同呢?
rom*_*inl 97
位置列表是当前窗口的本地列表,因此您可以拥有与窗口一样多的位置列表:30个窗口?没问题,这是您的30个并发位置列表.
quickfix列表是全局的,因此您一次不能有多个可用的列表.有些命令允许您将当前的quickfix列表替换为前一个,但是您不能有两个并发的quickfix列表.
不要将位置/ quickfix"列表"(数据结构)与位置/ quickfix"windows"(显示这些数据结构内容的窗口)混淆."窗口"有类似的行为,但"列表"没有.差别很重要,因为这些窗口不仅是与这些列表交互的唯一方式:有许多命令允许我们在不打开相关窗口的情况下浏览这些列表,并且知道这些列表之间的差异是有效使用这些命令的关键.
动手插图示例:
不要:lvim foo %
在foo.txt
创建包含窗口的位置列表foo.txt
.
做:lne
了几次跳几个foo
在foo.txt
.
专注bar.txt
并做:lne
.怎么了?
现在,:lvim bar %
进入bar.txt
为包含的窗口创建位置列表bar.txt
.
做:lne
几次.你跳到什么地方?在哪个缓冲区?在哪个窗口?
切换到另一个窗口并做:lne
几次.怎么了?
再次切换到bar.txt
.怎么:lne
办?
现在,做:vim bar %
在bar.txt
创建quickfix列表.
做:cn
了几次跳几个bar
在bar.txt
.
现在,关注foo.txt
,做:cn
什么?
您跳转到的位置:lne
取决于您所在的窗口,但跳转到的错误:cn
始终相同(直到您将当前的quickfix列表替换为另一个).
两个列表都有相对清晰的角色IMO:quickfix列表(因此quickfix窗口)通常和逻辑上专门用于错误,位置列表似乎(对我来说)适合搜索.