On 22/04/13 12:37, Thiago Padilha wrote:
I googled about this but only found how to open in a vertical split or
in a full window. I cannot find how can I navigate to help without
splitting or breaking my current layout.

Normally I already have two windows splitting the screen vertically and
would like to open help in the current window then navigate back with
ctrl+o. Any easy way to accomplish that?


Actually, the solution is simple, maybe so simple no one thought of it:

  :view $VIMRUNTIME/doc/help.txt

(assuming of course that there isn't yet an open help window). From then on, the :help and :helpgrep commands (and the <F1> keystroke) will return to the window where you viewed help.txt — but only as long as there is a helpfile in that window. You can go back from help.txt to whatever was there before with Ctrl-O but then that window loses its "help window" attribute and :help, :helpgrep or <F1> will open a new window.

So you can always open help for subject foobar in the current window by doing

  :view $VIMRUNTIME/doc/help.txt | help foobar

If you add the following mapping:

  :map <F1> :<C-U>view +1 $VIMRUNTIME/doc/help.txt<CR>

(where <C-U> clears any possible count or visual mode which may have been present when you hit <F1>, and the +1 means "with the cursor on line 1"), then <F1> does its usual job but in the current window, and you can open the help for any subject in the current window by hitting <F1> immediately before typing your :help (or :helpgrep) command.

Beware that with this mapping, if you hit <F1> while there _already_ is a help window in the current tab page, you will find yourself with a second help window open, and then I don't know which one of them will be affected by a following :help or :helpgrep command. Using

  :exe 'help' | q

will close an existing help window (if any), of course, but it may also leave you in a different window than before, so adding that (minus colon and plus a bar at the end) between <C-U> and view seems not to be a solution if you want to avoid the risk of opening a second help window.


Best regards,
Tony.
--
"I'll rob that rich person and give it to some poor deserving slob.
That will *prove* I'm Robin Hood."
                -- Daffy Duck, "Robin Hood Daffy", [1958, Chuck Jones]

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to