问题描述
比如说,我有以下映射:
Say, I have the following mapping:
map <F4> :execute "vimgrep /" .expand("<cword>") . "/j **" <Bar> cw<CR>
它(递归地)为光标下的单词实例搜索当前目录,并在快速修复列表窗口中打开这些文件.
which (recursively) greps the current directory for instances of the word under the cursor and opens these files in the quickfix list window.
如何从 quickfix 窗口启动我打开的文件到新选项卡? 只是将窗口中的当前缓冲区更改为该新文件.
From the quickfix window, how do I launch the file that I open into a new tab? just changes my current buffer in the window to that new file.
推荐答案
Quickfix-window 命令在创建时尊重 switchbuf
选项缓冲区.switchbuf
选项具有 newtab
说明符指示 Vim 在加载缓冲区之前打开一个新的标签页切换到.如果通过
Quickfix-window commands respect the switchbuf
option when creatingthe buffer. The switchbuf
option has the newtab
specifier thatinstructs Vim to open a new tab page before loading the buffer toswitch to. If one adds this key to the option via
:set switchbuf+=newtab
quickfix 窗口中的条目将在单独的选项卡中打开页.
the entries in the quickfix window will be opened in separate tabpages.
usetab
说明符在这方面也可能有用案件.它规定 Vim 切换到现有的标签页,如果它包含一个显示目标缓冲区的窗口,而不是复制它在一个新标签中.
There is the usetab
specifier that also might be useful in thiscase. It prescribes Vim to switch to an existing tab page if itcontains a window displaying the target buffer, instead of duplicatingit in a new tab.
:set switchbuf+=usetab,newtab
switchbuf
的值也(部分)影响其他缓冲区切换命令,例如:bfirst
、:blast
、:sbuffer
、:sbnext
和 :sbprevious
.
The value of switchbuf
also (partially) affects otherbuffer-switching commands, such as :bfirst
, :blast
, :sbuffer
,:sbnext
, and :sbprevious
.
这篇关于如何在新选项卡中制作 Vim 快速修复列表启动文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!