6

In vim docs, the description is very similar:

Quit:

:q[uit]
:{count}q[uit]
CTRL-W q                        *CTRL-W_q*
CTRL-W CTRL-Q                       *CTRL-W_CTRL-Q*
    Without {count}: Quit the current window.  If {count} is
    given quit the {count} window.

    When quitting the last window (not counting a help window),
    exit Vim.

    When 'hidden' is set, and there is only one window for the
    current buffer, it becomes hidden.  When 'hidden' is not set,
    and there is only one window for the current buffer, and the
    buffer was changed, the command fails.

    (Note: CTRL-Q does not work on all terminals).

    If [count] is greater than the last window number the last
    window will be closed: >
        :1quit  " quit the first window
        :$quit  " quit the last window
        :9quit  " quit the last window
             " if there are less than 9 windows opened
        :-quit  " quit the previews window
        :+quit  " quit the next window
        :+2quit " quit the second next window

Close:

:clo[se][!]
:{count}clo[se][!]
CTRL-W c                    *CTRL-W_c* *:clo* *:close*
    Without {count}: Close the current window.  If {count} is
    given close the {count} window.

    When the 'hidden' option is set, or when the buffer was
    changed and the [!] is used, the buffer becomes hidden (unless
    there is another window editing it).

    When there is only one window in the current tab page and
    there is another tab page, this closes the current tab page.
    |tab-page|.

    This command fails when:            *E444*
    - There is only one window on the screen.
    - When 'hidden' is not set, [!] is not used, the buffer has
      changes, and there is no other window on this buffer.
    Changes to the buffer are not written and won't get lost, so
    this is a "safe" command.
  • 4
    I would say the main difference is that :quit quits Vim when there is only one window whereas :close doesn't. – romainl Sep 7 '16 at 16:21
9

Open Vim and enter :close. You'll get:

E444: Cannot close last window

And this is the difference. We can also see this in the source implementation (from ex_docmd.c):

/*
 * ":quit": quit current window, quit Vim if the last window is closed.
 */
    static void
ex_quit(exarg_T *eap)
/*
 * ":close": close current window, unless it is the last one
 */
    static void
ex_close(exarg_T *eap)

Furthermore, if you compile Vim without window support only :quit is available (almost all − if not all − Vim builds are compiled with window support).

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.