Skip to main content
Module

x/denops_std/function/mod.ts>mapset

📚 Standard module for denops.vim
Go to Latest
function mapset
import { mapset } from "https://deno.land/x/denops_std@v4.1.2/function/mod.ts";

Restore a mapping from a dictionary, possibly returned by |maparg()| or |maplist()|. A buffer mapping, when dict.buffer is true, is set on the current buffer; it is up to the caller to ensure that the intended buffer is the current buffer. This feature allows copying mappings from one buffer to another. The dict.mode value may restore a single mapping that covers more than one mode, like with mode values of '!', ' ', 'nox', or 'v'. In the first form, {mode} and {abbr} should be the same as for the call to |maparg()|. {mode} is used to define the mode in which the mapping is set, not the "mode" entry in {dict}. Example for saving and restoring a mapping: let save_map = maparg('K', 'n', 0, 1) nnoremap K somethingelse ... call mapset('n', 0, save_map) Note that if you are going to replace a map in several modes, e.g. with :map!, you need to save/restore the mapping for all of them, when they might differ. In the second form, with {dict} as the only argument, mode and abbr are taken from the dict. Example: vim9script var save_maps = maplist()->filter( (_, m) => m.lhs == 'K') nnoremap K somethingelse cnoremap K somethingelse2 # ... unmap K for d in save_maps mapset(d) endfor

Parameters

denops: Denops
mode: unknown
abbr: unknown
dict: unknown

Returns

Promise<unknown>

Parameters

denops: Denops
dict: unknown

Returns

Promise<unknown>