Open multiple help windows in the same tab page

Viewed 169

When I have a help window open in vim, and I then search another topic in the help, I jump to the new topic (and away from the original one) in the original help window.

Is it possible to simply open a second help window, preferably in a new window split?

I'm used to opening multiple tabs when trouble shooting in my browser, and I feel limited when browsing Vim's help. This is especially the case when I'm reading the help, and then stumble across some vim feature that I wasn't looking for, but sounds interesting/useful.

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

2 Answers

You can prepend :tab to commands that split the window to force the new window to be opened in a new tab page:

:tab help :tab

That said, every jump to a new tag in the :help is stored in a :help tagstack so it is easy to backtrack with <C-t>.

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

The feature is introduced in chapter 8 of the user manual:

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.

Based on the answer from @romainl, coupled with the plugin Tabmerge, I've got a function that can open multiple help windows in the same tab page:

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

Defining a new command:

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

So to use it to open a new help window on the subject of tabs, even if you already have a help window open, do:

:NHelp tabs
Related