*event-args*
• id: (number) autocommand id
• event: (string) name of the triggered event
|autocmd-events|
• group: (number|nil) autocommand group id, if any
• file: (string) <afile> (not expanded to a full path)
• match: (string) <amatch> (expanded to a full path)
• buf: (number) <abuf>
• data: (any) arbitrary data passed from
|nvim_exec_autocmds()| *event-data*
• command (string) optional: Vim command to execute on event.
Cannot be used with {callback}
• once (boolean) optional: defaults to false. Run the
autocommand only once |autocmd-once|.
• nested (boolean) optional: defaults to false. Run nested
autocommands |autocmd-nested|.
Return: ~
Autocommand id (number)
See also: ~
• |autocommand|
• |nvim_del_autocmd()|
nvim_del_augroup_by_id({id}) *nvim_del_augroup_by_id()*
Delete an autocommand group by id.
To get a group id one can use |nvim_get_autocmds()|.
NOTE: behavior differs from |:augroup-delete|. When deleting a group,
autocommands contained in this group will also be deleted and cleared.
This group will no longer exist.
Attributes: ~
Since: 0.7.0
Parameters: ~
• {id} Integer The id of the group.
See also: ~
• |nvim_del_augroup_by_name()|
• |nvim_create_augroup()|
nvim_del_augroup_by_name({name}) *nvim_del_augroup_by_name()*
Delete an autocommand group by name.
NOTE: behavior differs from |:augroup-delete|. When deleting a group,
autocommands contained in this group will also be deleted and cleared.
This group will no longer exist.
Attributes: ~
Since: 0.7.0
Parameters: ~
• {name} String The name of the group.
See also: ~
• |autocmd-groups|
nvim_del_autocmd({id}) *nvim_del_autocmd()*
Deletes an autocommand by id.
Attributes: ~
Since: 0.7.0
Parameters: ~
• {id} Integer Autocommand id returned by |nvim_create_autocmd()|
nvim_exec_autocmds({event}, {opts}) *nvim_exec_autocmds()*
Execute all autocommands for {event} that match the corresponding {opts}
|autocmd-execute|.
Attributes: ~
Since: 0.7.0
Parameters: ~
• {event} (String|Array) The event or events to execute
• {opts} Dict of autocommand options:
• group (string|integer) optional: the autocommand group name
or id to match against. |autocmd-groups|.
• pattern (string|array) optional: defaults to "*"
|autocmd-pattern|. Cannot be used with {buffer}.
• buffer (integer) optional: buffer number
|autocmd-buflocal|. Cannot be used with {pattern}.
• modeline (bool) optional: defaults to true. Process the
modeline after the autocommands <nomodeline>.
• data (any): arbitrary data to send to the autocommand
callback. See |nvim_create_autocmd()| for details.
See also: ~
• |:doautocmd|
nvim_get_autocmds({opts}) *nvim_get_autocmds()*
Get all autocommands that match the corresponding {opts}.
These examples will get autocommands matching ALL the given criteria: >lua
-- Matches all criteria
autocommands = vim.api.nvim_get_autocmds({
group = 'MyGroup',
event = {'BufEnter', 'BufWinEnter'},
pattern = {'*.c', '*.h'}
})
-- All commands from one group
autocommands = vim.api.nvim_get_autocmds({
group = 'MyGroup',
})
<
NOTE: When multiple patterns or events