在同一标签页中打开多个帮助 windows

Open multiple help windows in the same tab page

当我在 vim 中打开帮助 window,然后在帮助中搜索另一个主题时,我会跳转到原始主题中的新主题(并远离原始主题)帮助 window.

是否可以简单地打开第二个帮助 window,最好是在新的 window 拆分中?

我习惯在浏览器中解决问题时打开多个选项卡,浏览 Vim 的帮助时感觉受限。尤其是当我阅读帮助时,偶然发现了一些我不想要但听起来 interesting/useful.

的 vim 功能

当然,我一直在 vim 的帮助文档中寻找答案,但没找到答案...

您可以在拆分 window 的命令前添加 :tab 以强制在新标签页中打开新的 window:

:tab help :tab

也就是说,:help 中每次跳转到新标签都存储在 :help tagstack 中,因此很容易用 <C-t> 回溯。

Of course I've been looking in vim's help documentation for the answer, but come up short...

该功能在用户手册第 8 章介绍:

You can put ":tab" before any Ex command that opens a window. The window will be opened in a new tab page. Another example:

:tab help gt

Will show the help text for "gt" in a new tab page.

根据@romainl的回答,结合插件Tabmerge,我得到了一个可以在同一个标​​签页打开多个帮助windows的功能:

function! NewHelpSplit(subject)
    let current_tabpage = string(tabpagenr())
    " open a help page in a new tab
    :execute ':tab :help ' a:subject
    " merge that tab as a split in current tab (bottom, means the original tab
    " content will be on the bottom, and therefore the help will be on the top)
    :execute ':Tabmerge ' current_tabpage ' bottom'
endfunction

正在定义一个新命令:

:command -nargs=1 NHelp :call NewHelpSplit("<args>")

因此,要使用它打开有关选项卡主题的新帮助 window,即使您已经打开帮助 window,请执行以下操作:

:NHelp tabs