1
0
forked from aniani/vim

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)
This commit is contained in:
zeertzjq
2022-09-12 13:38:41 +01:00
committed by Bram Moolenaar
parent 5a4eb55122
commit cdc839353f
9 changed files with 83 additions and 15 deletions

View File

@@ -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 = "\<C-Home>"
:echo keytrans(xx)
< <C-Home>
Can also be used as a |method|: >
"\<C-Home>"->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