How to exit help in vim

37

8

I just used the help files in vim and now I am stuck in help.

:q Exits the entire program and I am getting tired of having to close and reopen vim every time I use help. I would prefer a command that can close help and return me to the program I am writing.

I have trouble searching google.com because the search string exit help in vim obviously returns articles about exiting vim itself, something I have became very good at.

Does anyone know how to do this?

EDIT: I must have been somehow getting stuck in the split screen thing. That's why I was unable to get out of the help via :q

Joseph

Posted 2013-10-21T07:41:02.817

Reputation: 589

"...exiting vim itself, something I have become very good at." – Stack Underflow – 2019-05-23T19:59:39.340

Answers

40

:q is already the solution.

It closes not the whole vim session, but only the active window (split section within vim). If this is window is the help, only the help will be closed. If your document is active, the document will be closed.

If this is the last non-help window, the help will close as well -- which means vim is closed.

Use Ctrl+W followed by a cursor key to make sure your cursor is in the help window. Then try :q again.

Tim

Posted 2013-10-21T07:41:02.817

Reputation: 1 811

10

Recent Vims have the :helpclose command (this needs a Vim 7.4.449)

Christian Brabandt

Posted 2013-10-21T07:41:02.817

Reputation: 1 196

7

:q is a little bit annoying since this is a readonly buffer. And I believe people rarely need to record a macro in help buffer.

So I'd like to map q to :q:

autocmd FileType help noremap <buffer> q :q<cr>

Rocky

Posted 2013-10-21T07:41:02.817

Reputation: 171

3

I use Ctrl+W+C or Ctrl+W+Q, although I agree that like many other more modern read only windows, it would be more natural if we could quit it with just pressing q.

Andrzej Wąsowski

Posted 2013-10-21T07:41:02.817

Reputation: 131

2

You must have somehow arrived at a sole help window. Usually, :help splits a window, and a :q in that window will just close the help, and return to the other window.

Or, you've typed the :q while in the other window, not the help. Vim doesn't "count" help windows as full windows, and will quit completely when only help windows would be left.

There are quite some window management commands; for example, :close is a variant of :quit that won't exit Vim. Though initially confusing, learn how to use them, as they are very powerful. :help windows has all the information.

Ingo Karkat

Posted 2013-10-21T07:41:02.817

Reputation: 19 513