From cdc839353f68ca43db6446e1b727fc7ba657b738 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 12 Sep 2022 13:38:41 +0100 Subject: patch 9.0.0449: there is no easy way to translate a key code into a string Problem: There is no easy way to translate a string with a key code into a readable string. Solution: Add the keytrans() function. (closes #11114) --- runtime/doc/builtin.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'runtime/doc/builtin.txt') diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index 3448ed5855..fb8b116010 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -325,6 +325,8 @@ js_encode({expr}) String encode JS style JSON json_decode({string}) any decode JSON json_encode({expr}) String encode JSON keys({dict}) List keys in {dict} +keytrans({string}) String translate internal keycodes to a form + that can be used by |:map| len({expr}) Number the length of {expr} libcall({lib}, {func}, {arg}) String call {func} in library {lib} with {arg} libcallnr({lib}, {func}, {arg}) Number idem, but return a Number @@ -5205,6 +5207,16 @@ keys({dict}) *keys()* Can also be used as a |method|: > mydict->keys() +keytrans({string}) *keytrans()* + Turn the internal byte representation of keys into a form that + can be used for |:map|. E.g. > + :let xx = "\" + :echo keytrans(xx) +< + + Can also be used as a |method|: > + "\"->keytrans() + < *len()* *E701* len({expr}) The result is a Number, which is the length of the argument. When {expr} is a String or a Number the length in bytes is -- cgit v1.2.3