From 907fc8ac373226556b84c2fdc4fe26525bbdb2c4 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 13 Sep 2022 06:23:33 +0800 Subject: vim-patch:9.0.0449: there is no easy way to translate a key code into a string (#20168) Problem: There is no easy way to translate a string with a key code into a readable string. Solution: Add the keytrans() function. (closes vim/vim#11114) https://github.com/vim/vim/commit/cdc839353f68ca43db6446e1b727fc7ba657b738 vim-patch:7b2d87220c6c Add missing part of patch https://github.com/vim/vim/commit/7b2d87220c6c974d5cdae672b6f9620a6bcbd1dc --- runtime/doc/builtin.txt | 12 ++++++++++++ runtime/doc/usr_41.txt | 2 ++ 2 files changed, 14 insertions(+) (limited to 'runtime') diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index c70643d12c..7b1a50c1fb 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -277,6 +277,8 @@ join({list} [, {sep}]) String join {list} items into one String json_decode({expr}) any Convert {expr} from JSON json_encode({expr}) String Convert {expr} to 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 @@ -4537,6 +4539,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 diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt index ee644be366..1aa9aaa0c4 100644 --- a/runtime/doc/usr_41.txt +++ b/runtime/doc/usr_41.txt @@ -604,6 +604,8 @@ String manipulation: *string-functions* fnameescape() escape a file name for use with a Vim command tr() translate characters from one set to another strtrans() translate a string to make it printable + keytrans() translate internal keycodes to a form that + can be used by |:map| tolower() turn a string to lowercase toupper() turn a string to uppercase charclass() class of a character -- cgit