|
1 | | -*autocmd.txt* For Vim version 8.1. Last change: 2019 Mar 13 |
| 1 | +*autocmd.txt* For Vim version 8.1. Last change: 2019 Apr 04 |
2 | 2 |
|
3 | 3 |
|
4 | 4 | VIM REFERENCE MANUAL by Bram Moolenaar |
@@ -52,15 +52,21 @@ effects. Be careful not to destroy your text. |
52 | 52 | 2. Defining autocommands *autocmd-define* |
53 | 53 |
|
54 | 54 | *:au* *:autocmd* |
55 | | -:au[tocmd] [group] {event} {pat} [nested] {cmd} |
| 55 | +:au[tocmd] [group] {event} {pat} [++once] [++nested] {cmd} |
56 | 56 | Add {cmd} to the list of commands that Vim will |
57 | 57 | execute automatically on {event} for a file matching |
58 | 58 | {pat} |autocmd-patterns|. |
59 | 59 | Note: A quote character is seen as argument to the |
60 | 60 | :autocmd and won't start a comment. |
61 | 61 | Vim always adds the {cmd} after existing autocommands, |
62 | 62 | so that the autocommands execute in the order in which |
63 | | - they were given. See |autocmd-nested| for [nested]. |
| 63 | + they were given. |
| 64 | + See |autocmd-nested| for [++nested]. "nested" |
| 65 | + (without the ++) can also be used, for backwards |
| 66 | + compatibility. |
| 67 | + *autocmd-once* |
| 68 | + If [++once] is supplied the command is executed once, |
| 69 | + then removed ("one shot"). |
64 | 70 |
|
65 | 71 | The special pattern <buffer> or <buffer=N> defines a buffer-local autocommand. |
66 | 72 | See |autocmd-buflocal|. |
@@ -128,10 +134,11 @@ prompt. When one command outputs two messages this can happen anyway. |
128 | 134 | ============================================================================== |
129 | 135 | 3. Removing autocommands *autocmd-remove* |
130 | 136 |
|
131 | | -:au[tocmd]! [group] {event} {pat} [nested] {cmd} |
| 137 | +:au[tocmd]! [group] {event} {pat} [++once] [++nested] {cmd} |
132 | 138 | Remove all autocommands associated with {event} and |
133 | | - {pat}, and add the command {cmd}. See |
134 | | - |autocmd-nested| for [nested]. |
| 139 | + {pat}, and add the command {cmd}. |
| 140 | + See |autocmd-once| for [++once]. |
| 141 | + See |autocmd-nested| for [++nested]. |
135 | 142 |
|
136 | 143 | :au[tocmd]! [group] {event} {pat} |
137 | 144 | Remove all autocommands associated with {event} and |
@@ -1473,7 +1480,7 @@ By default, autocommands do not nest. For example, if you use ":e" or ":w" in |
1473 | 1480 | an autocommand, Vim does not execute the BufRead and BufWrite autocommands for |
1474 | 1481 | those commands. If you do want this, use the "nested" flag for those commands |
1475 | 1482 | in which you want nesting. For example: > |
1476 | | - :autocmd FileChangedShell *.c nested e! |
| 1483 | + :autocmd FileChangedShell *.c ++nested e! |
1477 | 1484 | The nesting is limited to 10 levels to get out of recursive loops. |
1478 | 1485 |
|
1479 | 1486 | It's possible to use the ":au" command in an autocommand. This can be a |
|
0 commit comments