Skip to content

Commit 14c0964

Browse files
committed
autocmd.txt: Update Vim 8.2.5077
1 parent e824bd6 commit 14c0964

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

en/autocmd.txt

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*autocmd.txt* For Vim version 8.2. Last change: 2022 Apr 17
1+
*autocmd.txt* For Vim version 8.2. Last change: 2022 May 24
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -47,6 +47,28 @@ effects. Be careful not to destroy your text.
4747
It's a good idea to use the same autocommands for the File* and Buf* events
4848
when possible.
4949

50+
Recommended use:
51+
- Always use a group, so that it's easy to delete the autocommand.
52+
- Keep the command itself short, call a function to do more work.
53+
- Make it so that the script it is defined in can be sourced several times
54+
without the autocommand being repeated.
55+
56+
Example in Vim9 script: >
57+
autocmd_add({replace: true,
58+
group: 'DemoGroup',
59+
event: 'BufEnter',
60+
pattern: '*.txt',
61+
cmd: 'call DemoBufEnter()'
62+
})
63+
64+
In legacy script: >
65+
call autocmd_add(#{replace: v:true,
66+
\ group: 'DemoGroup',
67+
\ event: 'BufEnter',
68+
\ pattern: '*.txt',
69+
\ cmd: 'call DemoBufEnter()'
70+
\ })
71+
5072
==============================================================================
5173
2. Defining autocommands *autocmd-define*
5274

@@ -82,6 +104,10 @@ triggered.
82104
/<start
83105
}
84106
107+
The |autocmd_add()| function can be used to add a list of autocmds and autocmd
108+
groups from a Vim script. It is preferred if you have anything that would
109+
require using `:execute` with `:autocmd`.
110+
85111
Note: The ":autocmd" command can only be followed by another command when the
86112
'|' appears where the pattern is expected. This works: >
87113
:augroup mine | au! BufRead | augroup END
@@ -146,6 +172,9 @@ prompt. When one command outputs two messages this can happen anyway.
146172
==============================================================================
147173
3. Removing autocommands *autocmd-remove*
148174

175+
In addition to the below described commands, the |autocmd_delete()| function can
176+
be used to remove a list of autocmds and autocmd groups from a Vim script.
177+
149178
:au[tocmd]! [group] {event} {aupat} [++once] [++nested] {cmd}
150179
Remove all autocommands associated with {event} and
151180
{aupat}, and add the command {cmd}.
@@ -198,6 +227,9 @@ argument behavior differs from that for defining and removing autocommands.
198227
In order to list buffer-local autocommands, use a pattern in the form <buffer>
199228
or <buffer=N>. See |autocmd-buflocal|.
200229

230+
The |autocmd_get()| function can be used from a Vim script to get a list of
231+
autocmds.
232+
201233
*:autocmd-verbose*
202234
When 'verbose' is non-zero, listing an autocommand will also display where it
203235
was last defined. Example: >

0 commit comments

Comments
 (0)