Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/denops_std/helper/mod.ts>send

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

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

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

export const main: Entrypoint = async (denops) => {
  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>