简体   繁体   English

让vim标签匹配列表打开一个新标签页

[英]have vim tag-matchlist open a new tab

I've got things configured so CTRL-] on a tag goes directly to the file in a new tab if there is only one match. 我已经配置好了东西,所以如果只有一个匹配项,标签上的CTRL-]会直接转到新标签中的文件。 If there are multiple matches, tag-matchlist appears in a new pane in the present tab. 如果存在多个匹配项,则标记匹配列表将出现在当前选项卡的新窗格中。 Hitting the number and enter then opens the entry in a split pane. 按下数字并输入,然后在拆分窗格中打开该条目。

How can I adjust things, please, so that either: 请问我该如何调整呢?

a) the tab-matchlist opens in a new tab a)标签匹配列表在新标签中打开

or 要么

b) the chosen entry will appear in a new tab b)所选条目将出现在新选项卡中

You can use the following mapping to show the matchlist for the tag under your cursor in the current window and open the chosen tag in a tab: 您可以使用以下映射在当前窗口中的光标下方显示标签的匹配列表,然后在标签中打开所选标签:

nnoremap <F6> :tab tselect <C-r><C-w><CR>

It is an alternative version of your mapping but a little less messy. 它是映射的替代版本,但有点混乱。

The following mapping yanks the tag under your cursor to register t , opens a new tab and does :tselect with register t (and thus shows the matchlist in that tab): 以下映射将光标下方的标记:tselect寄存器t ,打开一个新标签, :tselect对寄存器t执行:tselect (从而在该标签中显示匹配列表):

nnoremap <F7> "tyiw:tabnew<CR>:tselect <C-r>t<CR>

Figured out how to do exactly what I want: 弄清楚该怎么做我想要的:

nnoremap <C-]> :tab tjump <Cr><Cw><CR>

If there's one match, that jumps directly to the tag in a new tab. 如果有一个匹配项,它将直接跳转到新标签中的标签。

If there are multiple matches, that opens the tag-matchlist, then once the desired entry is selected, it jumps to that tag in a new tab. 如果存在多个匹配项,则会打开标签匹配列表,然后,一旦选择了所需的条目,它就会跳到新标签中的该标签。

Many thanks to @romainl for pointing me in the right direction. 非常感谢@romainl为我指出正确的方向。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM