Home Explore Blog CI



neovim

23th chunk of `runtime/doc/autocmd.txt`
5f1507ea37d966e9cc7402f0b73fba263a0d1549b16c8c0c000000010000087b
 anything in the
same line after it) with the current date and time.  Explanation:
	ks		mark current position with mark 's'
	call LastMod()  call the LastMod() function to do the work
	's		return the cursor to the old position
The LastMod() function checks if the file is shorter than 20 lines, and then
uses the ":g" command to find lines that contain "Last modified: ".  For those
lines the ":s" command is executed to replace the existing date with the
current one.  The ":execute" command is used to be able to use an expression
for the ":g" and ":s" commands.  The date is obtained with the strftime()
function.  You can change its argument to get another date string.

When entering :autocmd on the command-line, completion of events and command
names may be done (with <Tab>, CTRL-D, etc.) where appropriate.

Vim executes all matching autocommands in the order that you specify them.
It is recommended that your first autocommand be used for all files by using
"*" as the file pattern.  This means that you can define defaults you like
here for any settings, and if there is another matching autocommand it will
override these.  But if there is no other matching 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

Title: Autocommand Order, Search Patterns, and Cmd Events in Nvim
Summary
This section discusses the importance of autocommand order and the use of '*' for default settings. It also explains how Vim handles search patterns within autocommands, preserving them and offering a method to set them for use after the autocommand finishes. Lastly, it introduces '*Cmd' events and matching autocommands.