如何使 Vim 快速修复列表在新选项卡中启动文件? [英] How to make Vim quickfix list launch files in a new tab?

查看:12
本文介绍了如何使 Vim 快速修复列表在新选项卡中启动文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说,我有以下映射:

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.

如何从快速修复窗口启动我在新选项卡中打开的文件?Enter 只是将我在窗口中的当前缓冲区更改为那个新文件.

From the quickfix window, how do I launch the file that I open into a new tab? Enter 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 creating the buffer. The switchbuf option has the newtab specifier that instructs Vim to open a new tab page before loading the buffer to switch to. If one adds this key to the option via

:set switchbuf+=newtab

快速修复窗口中的条目将在单独的选项卡中打开页面.

the entries in the quickfix window will be opened in separate tab pages.

usetab 说明符也可能在此有用案件.它规定 Vim 切换到现有的标签页,如果它包含一个显示目标缓冲区的窗口,而不是复制它在一个新标签中.

There is the usetab specifier that also might be useful in this case. It prescribes Vim to switch to an existing tab page if it contains a window displaying the target buffer, instead of duplicating it in a new tab.

:set switchbuf+=usetab,newtab

switchbuf 的值也(部分)影响其他缓冲区切换命令,例如 :bfirst, :blast, :sbuffer,:sbnext:sbprevious.

The value of switchbuf also (partially) affects other buffer-switching commands, such as :bfirst, :blast, :sbuffer, :sbnext, and :sbprevious.

这篇关于如何使 Vim 快速修复列表在新选项卡中启动文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆