Home

QuitPre

QuitPre is an autocommand event in Vim and Neovim that fires immediately before a quitting operation is executed. It is part of the editor’s autocommand framework, which lets scripts respond to a wide range of editor events. QuitPre sits alongside other exit-related events such as QuitPost and VimLeavePre, and is documented in the editor’s help system (for example, via :help QuitPre).

The primary purpose of QuitPre is to allow plugins and user scripts to perform finalization tasks before

Usage examples are straightforward lines of autocommand definitions, such as:

autocmd QuitPre * call MyCleanup()

Because QuitPre runs before the quit process, it can be used to prepare for shutdown or to

Compatibility and scope notes: QuitPre is supported in both Vim and Neovim, with broad adoption across plugins.

the
editor
exits.
Typical
uses
include
running
cleanup
routines,
saving
session
data,
writing
out
temporary
state,
or
prompting
the
user
to
save
modified
buffers.
Autocommands
attached
to
QuitPre
are
invoked
whenever
a
quit
or
exit
sequence
is
initiated,
which
makes
it
a
common
integration
point
for
ensuring
that
necessary
actions
occur
prior
to
termination.
coordinate
with
other
plugins.
Depending
on
user
configuration
and
version,
its
exact
interaction
with
prompts
and
confirmations
may
vary,
but
the
event
remains
a
standard
hook
for
pre-exit
handling.
As
with
other
autocommand
events,
users
should
be
mindful
of
performance
and
avoid
lengthy
operations
in
QuitPre,
since
actions
here
execute
as
part
of
the
quit
sequence.