1
- *autocmd.txt* For Vim version 8.2. Last change: 2021 Jul 27
1
+ *autocmd.txt* For Vim version 8.2. Last change: 2021 Nov 20
2
2
3
3
4
4
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -76,8 +76,14 @@ and in a `:def` function) then {cmd} will be executed as in Vim9
76
76
script. Thus this depends on where the autocmd is defined, not where it is
77
77
triggered.
78
78
79
+ {cmd} can be a block, like with `:command ` , see | :command-repl | . Example: >
80
+ au BufReadPost *.xml {
81
+ setlocal matchpairs+=<:>
82
+ /<start
83
+ }
84
+
79
85
Note: The ":autocmd" command can only be followed by another command when the
80
- '|' appears before {cmd} . This works: >
86
+ '|' appears where the pattern is expected . This works: >
81
87
:augroup mine | au! BufRead | augroup END
82
88
But this sees "augroup" as part of the defined command: >
83
89
:augroup mine | au! BufRead * | augroup END
@@ -342,6 +348,7 @@ Name triggered by ~
342
348
343
349
| WinNew | after creating a new window
344
350
| TabNew | after creating a new tab page
351
+ | WinClosed | after closing a window
345
352
| TabClosed | after closing a tab page
346
353
| WinEnter | after entering another window
347
354
| WinLeave | before leaving a window
@@ -360,6 +367,8 @@ Name triggered by ~
360
367
| InsertCharPre | when a character was typed in Insert mode, before
361
368
inserting it
362
369
370
+ | ModeChanged | after changing the mode
371
+
363
372
| TextChanged | after a change was made to the text in Normal mode
364
373
| TextChangedI | after a change was made to the text in Insert mode
365
374
when popup menu is not visible
@@ -700,7 +709,7 @@ EncodingChanged Fires off after the 'encoding' option has been
700
709
*FileAppendCmd*
701
710
FileAppendCmd Before appending to a file. Should do the
702
711
appending to the file. Use the '[ and ']
703
- marks for the range of lines.| Cmd-event |
712
+ marks for the range of lines. | Cmd-event |
704
713
*FileAppendPost*
705
714
FileAppendPost After appending to a file.
706
715
*FileAppendPre*
@@ -828,7 +837,7 @@ FilterReadPre Before reading a file from a filter command.
828
837
*FilterWritePost*
829
838
FilterWritePost After writing a file for a filter command or
830
839
making a diff with an external diff (see
831
- DiffUpdated for internal diff).
840
+ | DiffUpdated | for internal diff).
832
841
Vim checks the pattern against the name of
833
842
the current buffer as with FilterWritePre.
834
843
Not triggered when 'shelltemp' is off.
@@ -919,7 +928,27 @@ MenuPopup Just before showing the popup menu (under the
919
928
i Insert
920
929
c Command line
921
930
tl Terminal
922
- *OptionSet*
931
+ *ModeChanged*
932
+ ModeChanged After changing the mode. The pattern is
933
+ matched against `' old_mode:new_mode' ` , for
934
+ example match against `* :c * ` to simulate
935
+ | CmdlineEnter | .
936
+ The following values of | v:event | are set:
937
+ old_mode The mode before it changed.
938
+ new_mode The new mode as also returned
939
+ by | mode() | called with a
940
+ non-zero argument.
941
+ When ModeChanged is triggered, old_mode will
942
+ have the value of new_mode when the event was
943
+ last triggered.
944
+ This will be triggered on every minor mode
945
+ change.
946
+ Usage example to use relative line numbers
947
+ when entering Visual mode: >
948
+ :au ModeChanged [vV\x16]*:* let &l:rnu = mode() =~# '^[vV\x16]'
949
+ :au ModeChanged *:[vV\x16]* let &l:rnu = mode() =~# '^[vV\x16]'
950
+ :au WinEnter,WinLeave * let &l:rnu = mode() =~# '^[vV\x16]'
951
+ < *OptionSet*
923
952
OptionSet After setting an option. The pattern is
924
953
matched against the long option name.
925
954
| <amatch> | indicates what option has been set.
@@ -1172,9 +1201,9 @@ TextYankPost After text has been yanked or deleted in the
1172
1201
register, as a list of lines,
1173
1202
like with: >
1174
1203
getreg(r, 1, 1)
1175
- < regname Name of the | register | or
1176
- empty string for the unnamed
1177
- register.
1204
+ < regname Name of the register or empty
1205
+ string for the unnamed
1206
+ register, see | registers | .
1178
1207
regtype Type of the register, see
1179
1208
| getregtype() | .
1180
1209
visual True if the operation is
@@ -1252,6 +1281,12 @@ VimResume When the Vim instance is resumed after being
1252
1281
VimSuspend When the Vim instance is suspended. Only when
1253
1282
CTRL-Z was typed inside Vim, not when the
1254
1283
SIGSTOP or SIGTSTP signal was sent to Vim.
1284
+ *WinClosed*
1285
+ WinClosed After closing a window. The pattern is
1286
+ matched against the | window-ID | . Both
1287
+ <amatch> and <afile> are set to the
1288
+ | window-ID | . Non-recursive (event cannot
1289
+ trigger itself).
1255
1290
*WinEnter*
1256
1291
WinEnter After entering another window. Not done for
1257
1292
the first window, when Vim has just started.
@@ -1479,6 +1514,13 @@ Example: >
1479
1514
This prevents having the autocommands defined twice (e.g., after sourcing the
1480
1515
.vimrc file again).
1481
1516
1517
+ *FileExplorer*
1518
+ There is one group that is recognized by Vim: FileExplorer. If this group
1519
+ exists Vim assumes that editing a directory is possible and will trigger a
1520
+ plugin that lists the files in that directory. This is used by the | netrw |
1521
+ plugin. This allows you to do: >
1522
+ browse edit
1523
+
1482
1524
==============================================================================
1483
1525
9. Executing autocommands *autocmd-execute*
1484
1526
0 commit comments