diff runtime/doc/eval.txt @ 20506:aee0b72ca6d6 v8.2.0807

patch 8.2.0807: cannot easily restore a mapping Commit: https://github.com/vim/vim/commit/4c9243f9fb708c9010867d3cc8e928f36b58509a Author: Bram Moolenaar <Bram@vim.org> Date: Fri May 22 13:10:44 2020 +0200 patch 8.2.0807: cannot easily restore a mapping Problem: Cannot easily restore a mapping. Solution: Add mapset().
author Bram Moolenaar <Bram@vim.org>
date Fri, 22 May 2020 13:15:04 +0200
parents 3b3589275ab9
children 729853a754ea
line wrap: on
line diff
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -2586,6 +2586,8 @@ maparg({name} [, {mode} [, {abbr} [, {di
 					rhs of mapping {name} in mode {mode}
 mapcheck({name} [, {mode} [, {abbr}]])
 				String	check for mappings matching {name}
+mapset({name}, {mode}, {abbr}, {dict}
+				none	restore mapping from |maparg()| result
 match({expr}, {pat} [, {start} [, {count}]])
 				Number	position where {pat} matches in {expr}
 matchadd({group}, {pattern} [, {priority} [, {id} [, {dict}]]])
@@ -6794,6 +6796,7 @@ map({expr1}, {expr2})					*map()*
 		Can also be used as a |method|: >
 			mylist->map(expr2)
 
+
 maparg({name} [, {mode} [, {abbr} [, {dict}]]])			*maparg()*
 		When {dict} is omitted or zero: Return the rhs of mapping
 		{name} in mode {mode}.  The returned String has special
@@ -6844,6 +6847,10 @@ maparg({name} [, {mode} [, {abbr} [, {di
 		  "lnum"     The line number in "sid", zero if unknown.
 		  "nowait"   Do not wait for other, longer mappings.
 			     (|:map-<nowait>|).
+		  "simplified"
+
+		The dictionary can be used to restore a mapping with
+		|mapset()|.
 
 		The mappings local to the current buffer are checked first,
 		then the global mappings.
@@ -6890,6 +6897,18 @@ mapcheck({name} [, {mode} [, {abbr}]])		
 		Can also be used as a |method|: >
 			GetKey()->mapcheck('n')
 
+mapset({mode}, {abbr}, {dict})				*mapset()*
+		Restore a mapping from a dictionary returned by |maparg()|.
+		{name}, {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)
+<
 match({expr}, {pat} [, {start} [, {count}]])			*match()*
 		When {expr} is a |List| then this returns the index of the
 		first item where {pat} matches.  Each item is used as a