Skip to main content
Deno 2 is finally here ๐ŸŽ‰๏ธ
Learn more
Module

x/denops_std/function/vim/mod.ts>autocmd_add

๐Ÿ“š Standard module for denops.vim
Go to Latest
function autocmd_add
import { autocmd_add } from "https://deno.land/x/denops_std@v6.3.0/function/vim/mod.ts";

Adds a List of autocmds and autocmd groups.

The {acmds} argument is a List where each item is a Dict with the following optional items: bufnr buffer number to add a buffer-local autocmd. If this item is specified, then the "pattern" item is ignored. cmd Ex command to execute for this autocmd event event autocmd event name. Refer to autocmd-events. This can be either a String with a single event name or a List of event names. group autocmd group name. Refer to autocmd-groups. If this group doesn't exist then it is created. If not specified or empty, then the default group is used. nested boolean flag, set to v:true to add a nested autocmd. Refer to autocmd-nested. once boolean flag, set to v:true to add an autocmd which executes only once. Refer to autocmd-once. pattern autocmd pattern string. Refer to autocmd-patterns. If "bufnr" item is present, then this item is ignored. This can be a String with a single pattern or a List of patterns. replace boolean flag, set to v:true to remove all the commands associated with the specified autocmd event and group and add the {cmd}. This is useful to avoid adding the same command multiple times for an autocmd event in a group.

Returns v:true on success and v:false on failure. Examples:

" Create a buffer-local autocmd for buffer 5
let acmd = {}
let acmd.group = 'MyGroup'
let acmd.event = 'BufEnter'
let acmd.bufnr = 5
let acmd.cmd = 'call BufEnterFunc()'
call autocmd_add([acmd])

Can also be used as a method:

GetAutocmdList()->autocmd_add()

Parameters

denops: Denops
acmds: unknown

Returns

Promise<boolean>