Home Explore Blog CI



neovim

24th chunk of `runtime/doc/autocmd.txt`
db6eb30dbe629cb3212924cc56299a715be8c365bee552c90000000100000c4c
 autocommand, then at least
your default settings are recovered (if entering this file from another for
which autocommands did match).  Note that "*" will also match files starting
with ".", unlike Unix shells.

						    *autocmd-searchpat*
Autocommands do not change the current search patterns.  Vim saves the current
search patterns before executing autocommands then restores them after the
autocommands finish.  This means that autocommands do not affect the strings
highlighted with the 'hlsearch' option.  Within autocommands, you can still
use search patterns normally, e.g., with the "n" command.
If you want an autocommand to set the search pattern, such that it is used
after the autocommand finishes, use the ":let @/ =" command.
The search-highlighting cannot be switched off with ":nohlsearch" in an
autocommand.  Use the 'h' flag in the 'shada' option to disable search-
highlighting when starting Vim.

							*Cmd-event*
When using one of the "*Cmd" events, the matching autocommands are expected to
do the file reading, writing or sourcing.  This can be used when working with
a special kind of file, for example on a remote system.
CAREFUL: If you use these events in a wrong way, it may have the effect of
making it impossible to read or write the matching files!  Make sure you test
your autocommands properly.  Best is to use a pattern that will never match a
normal file name, for example "ftp://*".

When defining a BufReadCmd it will be difficult for Vim to recover a crashed
editing session.  When recovering from the original file, Vim reads only those
parts of a file that are not found in the swap file.  Since that is not
possible with a BufReadCmd, use the |:preserve| command to make sure the
original file isn't needed for recovery.  You might want to do this only when
you expect the file to be modified.

For file read and write commands the |v:cmdarg| variable holds the "++enc="
and "++ff=" argument that are effective.  These should be used for the command
that reads/writes the file.  The |v:cmdbang| variable is one when "!" was
used, zero otherwise.

See the $VIMRUNTIME/pack/dist/opt/netrw/plugin/netrwPlugin.vim for examples.

==============================================================================
11. Disabling autocommands				*autocmd-disable*

To disable autocommands for some time use the 'eventignore' option.  Note that
this may cause unexpected behavior, make sure you restore 'eventignore'
afterwards, using a |:try| block with |:finally|.

To disable autocmds indefinitely in a specific window use the 'eventignorewin'
option.  This can only be used to ignore window and buffer related events.

							*:noautocmd* *:noa*
To disable autocommands for just one command use the ":noautocmd" command
modifier.  This will set 'eventignore' to "all" for the duration of the
following command.  Example: >

	:noautocmd w fname.gz

This will write the file without triggering the autocommands defined by the
gzip plugin.

Note that some autocommands are not triggered right away, but only later.
This specifically applies to |CursorMoved| and |TextChanged|.


 vim:tw=78:ts=8:noet:ft=help:norl:

Title: Cmd Events, Disabling Autocommands, and Event Ignoring in Nvim
Summary
This section explains the use of '*Cmd' events for file operations, emphasizing the need for caution and proper testing. It also details how to disable autocommands temporarily or indefinitely using the 'eventignore' and 'eventignorewin' options, as well as the ':noautocmd' command modifier. The section also reminds about the delayed execution of CursorMoved and TextChanged events.