47

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

45

: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.

| improve this answer | |
15

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

| improve this answer | |
11

: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>
| improve this answer | |
  • This is what I came in for, thank you! – Gal Nov 29 at 15:31
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.

| improve this answer | |
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.

| improve this answer | |
1

:bd will unload the current buffer (exit help) and return you to the last used buffer.

The command will not exit vim.

For example, the commands:

:help :bd
:only
:bd

will not exit vim despite the session having only 1 window.

| improve this answer | |
  • Yes, it works! It works also with help window opened in a new tab: :tab help foo. But it does not look logical because help is absent in the list returned by :buffers command... – nickkzl Sep 22 at 20:28
0

I know this is late, but there is a shortcut for :q which is ZQ. ZQ is quit without saving. In the same way if you want to quit with save, then use ZZ(this is similar to :wq).

| improve this answer | |
New contributor
theprogrammer is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.