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

x/denops_std/autocmd/mod.ts>group

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

Create an autocmd group and define/remove autocmds in that group.

import { Denops } from "../mod.ts";
import { group } from "./group.ts";

export async function main(denops: Denops): Promise<void> {
  await group(denops, "my-autocmd", (helper) => {
    // Define new autocmd for BufEnter
    helper.define("BufEnter", "*", "echo 'BufEnter'");

    // Define new autocmd for BufEnter with '++once'
    helper.define("BufEnter", "*", "echo 'BufEnter'", {
      once: true,
    });

    // Define new autocmd for BufEnter with '++nested'
    helper.define("BufEnter", "*", "echo 'BufEnter'", {
      nested: true,
    });

    // Define multiple autocmds
    helper.define(["BufEnter", "WinEnter"], "*", "echo 'Enter'");

    // Remove BufEnter autocmd
    helper.remove("BufEnter", "*");

    // Remove any autocmd in buffer
    helper.remove("*", "<buffer>");

    // Remove multiple autocmds
    helper.remove(["BufEnter", "WinEnter"], "*");
  });
}

This is preferable way to define autocmd while it define autocmds in an isolated autocmd group and the number of RPC calls is minimized.

Parameters

denops: Denops
name: string
executor: (helper: GroupHelper) => void

Returns

Promise<void>