that matches with {name} in mode
{mode}. See |maparg()| for {mode} and special names in
{name}.
When {abbr} is there and it is non-zero use abbreviations
instead of mappings.
A match happens with a mapping that starts with {name} and
with a mapping which is equal to the start of {name}.
matches mapping "a" "ab" "abc" ~
mapcheck("a") yes yes yes
mapcheck("abc") yes yes yes
mapcheck("ax") yes no no
mapcheck("b") no no no
The difference with maparg() is that mapcheck() finds a
mapping that matches with {name}, while maparg() only finds a
mapping for {name} exactly.
When there is no mapping that starts with {name}, an empty
String is returned. If there is one, the RHS of that mapping
is returned. If there are several mappings that start with
{name}, the RHS of one of them is returned. This will be
"<Nop>" if the RHS is empty.
The mappings local to the current buffer are checked first,
then the global mappings.
This function can be used to check if a mapping can be added
without being ambiguous. Example: >vim
if mapcheck("_vv") == ""
map _vv :set guifont=7x13<CR>
endif
< This avoids adding the "_vv" mapping when there already is a
mapping for "_v" or for "_vvv".
Parameters: ~
• {name} (`string`)
• {mode} (`string?`)
• {abbr} (`boolean?`)
Return: ~
(`any`)
maplist([{abbr}]) *maplist()*
Returns a |List| of all mappings. Each List item is a |Dict|,
the same as what is returned by |maparg()|, see
|mapping-dict|. When {abbr} is there and it is |TRUE| use
abbreviations instead of mappings.
Example to show all mappings with "MultiMatch" in rhs: >vim
echo maplist()->filter({_, m ->
\ match(get(m, 'rhs', ''), 'MultiMatch') >= 0
\ })
< It can be tricky to find mappings for particular |:map-modes|.
|mapping-dict|'s "mode_bits" can simplify this. For example,
the mode_bits for Normal, Insert or Command-line modes are
0x19. To find all the mappings available in those modes you
can do: >vim
let saved_maps = []
for m in maplist()
if and(m.mode_bits, 0x19) != 0
eval saved_maps->add(m)
endif
endfor
echo saved_maps->mapnew({_, m -> m.lhs})
< The values of the mode_bits are defined in Nvim's
src/nvim/state_defs.h file and they can be discovered at
runtime using |:map-commands| and "maplist()". Example: >vim
omap xyzzy <Nop>
let op_bit = maplist()->filter(
\ {_, m -> m.lhs == 'xyzzy'})[0].mode_bits
ounmap xyzzy
echo printf("Operator-pending mode bit: 0x%x", op_bit)
<
Parameters: ~
• {abbr} (`0|1?`)
Return: ~
(`table[]`)
mapnew({expr1}, {expr2}) *mapnew()*
Like |map()| but instead of replacing items in {expr1} a new
List or Dictionary is created and returned. {expr1} remains
unchanged. Items can still be changed by {expr2}, if you
don't want that use |deepcopy()| first.
Parameters: ~
• {expr1} (`any`)
• {expr2} (`any`)
Return: ~
(`any`)
mapset({mode}, {abbr}, {dict}) *mapset()*
mapset({dict})
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'. *E1276*
In the first form, {mode} and {abbr} should be the same as
for the call to |maparg()|. *E460*
{mode} is used to define the mode in