diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-04-04 15:04:56 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-04-04 15:04:56 +0200 |
commit | eb93f3f0e2b2ae65c5c3f55be3e62d64e3066f35 (patch) | |
tree | e69acd4b5050a07bfc91cb180831c5cd1bb41b1f /runtime/doc/autocmd.txt | |
parent | 87f59b09ea4b9af2712598374a6044f5fa1b54a4 (diff) |
patch 8.1.1113: making an autocommand trigger once is not so easyv8.1.1113
Problem: Making an autocommand trigger once is not so easy.
Solution: Add the ++once argument. Also add ++nested as an alias for
"nested". (Justin M. Keyes, closes #4100)
Diffstat (limited to 'runtime/doc/autocmd.txt')
-rw-r--r-- | runtime/doc/autocmd.txt | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt index 6480d72da0..5eb1936c48 100644 --- a/runtime/doc/autocmd.txt +++ b/runtime/doc/autocmd.txt @@ -1,4 +1,4 @@ -*autocmd.txt* For Vim version 8.1. Last change: 2019 Mar 13 +*autocmd.txt* For Vim version 8.1. Last change: 2019 Apr 04 VIM REFERENCE MANUAL by Bram Moolenaar @@ -52,7 +52,7 @@ effects. Be careful not to destroy your text. 2. Defining autocommands *autocmd-define* *:au* *:autocmd* -:au[tocmd] [group] {event} {pat} [nested] {cmd} +:au[tocmd] [group] {event} {pat} [++once] [++nested] {cmd} Add {cmd} to the list of commands that Vim will execute automatically on {event} for a file matching {pat} |autocmd-patterns|. @@ -60,7 +60,13 @@ effects. Be careful not to destroy your text. :autocmd and won't start a comment. Vim always adds the {cmd} after existing autocommands, so that the autocommands execute in the order in which - they were given. See |autocmd-nested| for [nested]. + they were given. + See |autocmd-nested| for [++nested]. "nested" + (without the ++) can also be used, for backwards + compatibility. + *autocmd-once* + If [++once] is supplied the command is executed once, + then removed ("one shot"). The special pattern <buffer> or <buffer=N> defines a buffer-local autocommand. See |autocmd-buflocal|. @@ -128,10 +134,11 @@ prompt. When one command outputs two messages this can happen anyway. ============================================================================== 3. Removing autocommands *autocmd-remove* -:au[tocmd]! [group] {event} {pat} [nested] {cmd} +:au[tocmd]! [group] {event} {pat} [++once] [++nested] {cmd} Remove all autocommands associated with {event} and - {pat}, and add the command {cmd}. See - |autocmd-nested| for [nested]. + {pat}, and add the command {cmd}. + See |autocmd-once| for [++once]. + See |autocmd-nested| for [++nested]. :au[tocmd]! [group] {event} {pat} 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 an autocommand, Vim does not execute the BufRead and BufWrite autocommands for those commands. If you do want this, use the "nested" flag for those commands in which you want nesting. For example: > - :autocmd FileChangedShell *.c nested e! + :autocmd FileChangedShell *.c ++nested e! The nesting is limited to 10 levels to get out of recursive loops. It's possible to use the ":au" command in an autocommand. This can be a |