diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-03-10 04:32:58 +0100 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2019-03-10 04:58:30 +0100 |
commit | c12cf5bde7a00fbc1a78ad762e61caae1f6d4188 (patch) | |
tree | ca2af046d87a885295604ad6bab3d21820c8bc3f /runtime | |
parent | 092e7e6c60588463389182a3babde9f4ee98bc1c (diff) | |
download | rneovim-c12cf5bde7a00fbc1a78ad762e61caae1f6d4188.tar.gz rneovim-c12cf5bde7a00fbc1a78ad762e61caae1f6d4188.tar.bz2 rneovim-c12cf5bde7a00fbc1a78ad762e61caae1f6d4188.zip |
autocmd: introduce "once" feature
Adds a new feature to :autocmd which sets the handler to be executed at
most one times.
Before:
augroup FooGroup
autocmd!
autocmd FileType foo call Foo() | autocmd! FooGroup * <buffer>
augroup END
After:
autocmd FileType foo once call Foo()
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/doc/autocmd.txt | 21 | ||||
-rw-r--r-- | runtime/doc/vim_diff.txt | 1 |
2 files changed, 13 insertions, 9 deletions
diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt index 6423939b83..203584e280 100644 --- a/runtime/doc/autocmd.txt +++ b/runtime/doc/autocmd.txt @@ -40,15 +40,18 @@ 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|. Note: A quote character is seen as argument to the :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]. + Nvim always adds {cmd} after existing autocommands so + they execute in the order in which they were defined. + See |autocmd-nested| for [nested]. + *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|. @@ -116,10 +119,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 @@ -1323,8 +1327,7 @@ option will not cause any commands to be executed. another extension. Example: > :au BufEnter *.cpp so ~/.config/nvim/init_cpp.vim :au BufEnter *.cpp doau BufEnter x.c -< Be careful to avoid endless loops. See - |autocmd-nested|. +< Be careful to avoid endless loops. |autocmd-nested| When the [group] argument is not given, Vim executes the autocommands for all groups. When the [group] diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt index 25517e506b..25ca2974bc 100644 --- a/runtime/doc/vim_diff.txt +++ b/runtime/doc/vim_diff.txt @@ -133,6 +133,7 @@ Command-line highlighting: removed in the future). Commands: + |:autocmd| accepts the `once` flag |:checkhealth| |:cquit| can use [count] to set the exit code |:drop| is always available |