Skip to main content
Module

x/denops_std/helper/keymap.ts>send

📚 Standard module for denops.vim
Go to Latest
function send
import { send } from "https://deno.land/x/denops_std@v6.3.0/helper/keymap.ts";

Send key sequences synchronously. denops#request blocks, so note that it can only be used within denops#notify.

import type { Denops } from "https://deno.land/x/denops_std@v6.3.0/mod.ts";
import * as fn from "https://deno.land/x/denops_std@v6.3.0/function/mod.ts";
import { exprQuote as q } from "https://deno.land/x/denops_std@v6.3.0/helper/expr_string.ts";
import { send } from "https://deno.land/x/denops_std@v6.3.0/helper/keymap.ts";

export async function main(denops: Denops): Promise<void> {
  denops.dispatcher = {
    send: async (): Promise<void> => {
      // Let's say the current buffer is "foo".
      await send(denops, "bar");
      // The buffer has been changed!
      // "foobar"
      console.log(await fn.getline(denops, "."));

      // Send special keys.
      await send(denops, [
        q`${"\\<BS>".repeat(6)}`,
        "baz",
      ]);
      // "baz"
      console.log(await fn.getline(denops, "."));

      // Send remaped keys.
      await send(denops, { keys: q`\<C-l>`, remap: true });
      // "bazsend"
      console.log(await fn.getline(denops, "."));
    },
  };
  await denops.cmd(`inoremap <C-k> <Cmd>call denops#notify('${denops.name}', 'send', [])<CR>`);
  await denops.cmd(`inoremap <C-l> send`);
}

Returns

Promise<void>