command-line – ¿Cuál es la diferencia entre los comandos: quit y: close?

Pregunta:

En vim docs, la descripción es muy similar:

Renunciar:

: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

Cerca:

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

Respuesta:

Abra Vim e ingrese :close . Usted obtendrá:

E444: Cannot close last window

Y esta es la diferencia. También podemos ver esto en la implementación de la fuente (de 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)

Además, si compila Vim sin soporte de ventana únicamente :quit está disponible (casi todas, si no todas, las compilaciones de Vim se compilan con soporte de ventana).

Leave a Comment

Your email address will not be published.

Scroll to Top

istanbul avukat

-

web tasarım