Skip to main content
Module

x/denops_std/function/mod.ts>hasmapto

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

The result is a Number, which is TRUE if there is a mapping that contains {what} in somewhere in the rhs (what it is mapped to) and this mapping exists in one of the modes indicated by {mode}. The arguments {what} and {mode} are strings. When {abbr} is there and it is TRUE use abbreviations instead of mappings. Don't forget to specify Insert and/or Command-line mode. Both the global mappings and the mappings local to the current buffer are checked for a match. If no matching mapping is found FALSE is returned. The following characters are recognized in {mode}: n Normal mode v Visual and Select mode x Visual mode s Select mode o Operator-pending mode i Insert mode l Language-Argument ("r", "f", "t", etc.) c Command-line mode When {mode} is omitted, "nvo" is used.

This function is useful to check if a mapping already exists to a function in a Vim script. Example:

:if !hasmapto('\ABCdoit')
:   map <Leader>d \ABCdoit
:endif

This installs the mapping to "\ABCdoit" only if there isn't already a mapping to "\ABCdoit".

Can also be used as a method:

GetRHS()->hasmapto()

Parameters

denops: Denops
what: unknown
optional
mode: unknown
optional
abbr: unknown

Returns

Promise<number>