diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-05-04 18:29:18 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-04 18:29:18 +0800 |
commit | 7ae57435be1af17cfb053087e08c6ba313522990 (patch) | |
tree | b198a34d1a29f25bb8d2f207f857be06a7838d8d /runtime | |
parent | 38f9ee63660740ce1976173a8513b57bc41d94a3 (diff) | |
parent | 8752da89b83281426e81e5c4a392308848f4bfb6 (diff) | |
download | rneovim-7ae57435be1af17cfb053087e08c6ba313522990.tar.gz rneovim-7ae57435be1af17cfb053087e08c6ba313522990.tar.bz2 rneovim-7ae57435be1af17cfb053087e08c6ba313522990.zip |
Merge pull request #23470 from zeertzjq/vim-8.2.2344
vim-patch:8.2.{1461,1462,1466,2344,2607,2756}
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/doc/builtin.txt | 29 | ||||
-rw-r--r-- | runtime/doc/eval.txt | 8 | ||||
-rw-r--r-- | runtime/doc/usr_41.txt | 3 |
3 files changed, 35 insertions, 5 deletions
diff --git a/runtime/doc/builtin.txt b/runtime/doc/builtin.txt index b37ac117f3..c2dc5ddd5b 100644 --- a/runtime/doc/builtin.txt +++ b/runtime/doc/builtin.txt @@ -464,6 +464,8 @@ sign_unplacelist({list}) List unplace a list of signs simplify({filename}) String simplify filename as much as possible sin({expr}) Float sine of {expr} sinh({expr}) Float hyperbolic sine of {expr} +slice({expr}, {start} [, {end}]) String, List or Blob + slice of a String, List or Blob sockconnect({mode}, {address} [, {opts}]) Number Connects to socket sort({list} [, {func} [, {dict}]]) @@ -484,7 +486,7 @@ str2list({expr} [, {utf8}]) List convert each character of {expr} to str2nr({expr} [, {base} [, {quoted}]]) Number convert String to Number strcharlen({expr}) Number character length of the String {expr} -strcharpart({str}, {start} [, {len}]) +strcharpart({str}, {start} [, {len} [, {skipcc}]]) String {len} characters of {str} at character {start} strchars({expr} [, {skipcc}]) Number character count of the String {expr} @@ -7773,6 +7775,19 @@ sinh({expr}) *sinh()* Can also be used as a |method|: > Compute()->sinh() +slice({expr}, {start} [, {end}]) *slice()* + Similar to using a |slice| "expr[start : end]", but "end" is + used exclusive. And for a string the indexes are used as + character indexes instead of byte indexes. + Also, composing characters are not counted. + When {end} is omitted the slice continues to the last item. + When {end} is -1 the last item is omitted. + Returns an empty value if {start} or {end} are invalid. + + Can also be used as a |method|: > + GetList()->slice(offset) + + sockconnect({mode}, {address} [, {opts}]) *sockconnect()* Connect a socket to an address. If {mode} is "pipe" then {address} should be the path of a local domain socket (on @@ -8115,12 +8130,16 @@ strcharlen({string}) *strcharlen()* GetText()->strcharlen() -strcharpart({src}, {start} [, {len}]) *strcharpart()* +strcharpart({src}, {start} [, {len} [, {skipcc}]]) *strcharpart()* Like |strpart()| but using character index and length instead - of byte index and length. Composing characters are counted - separately. + of byte index and length. + When {skipcc} is omitted or zero, composing characters are + counted separately. + When {skipcc} set to 1, Composing characters are ignored, + similar to |slice()|. When a character index is used where a character does not - exist it is assumed to be one character. For example: > + exist it is omitted and counted as one character. For + example: > strcharpart('abc', -1, 2) < results in 'a'. diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 0c18fd5b4e..05fdf2f5bb 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -270,6 +270,9 @@ similar to -1. > :let shortlist = mylist[2:2] " List with one item: [3] :let otherlist = mylist[:] " make a copy of the List +Notice that the last index is inclusive. If you prefer using an exclusive +index use the |slice()| method. + If the first index is beyond the last item of the List or the second item is before the first item, the result is an empty list. There is no error message. @@ -1152,6 +1155,8 @@ text column numbers start with one! Example, to get the byte under the cursor: > :let c = getline(".")[col(".") - 1] +Index zero gives the first byte. Careful: text column numbers start with one! + If the length of the String is less than the index, the result is an empty String. A negative index always results in an empty string (reason: backward compatibility). Use [-1:] to get the last byte. @@ -1176,6 +1181,9 @@ In legacy Vim script the indexes are byte indexes. This doesn't recognize multibyte encodings, see |byteidx()| for computing the indexes. If expr8 is a Number it is first converted to a String. +The item at index expr1b is included, it is inclusive. For an exclusive index +use the |slice()| function. + If expr1a is omitted zero is used. If expr1b is omitted the length of the string minus one is used. diff --git a/runtime/doc/usr_41.txt b/runtime/doc/usr_41.txt index 8e1b72eadc..9075d60b1b 100644 --- a/runtime/doc/usr_41.txt +++ b/runtime/doc/usr_41.txt @@ -630,6 +630,8 @@ String manipulation: *string-functions* submatch() get a specific match in ":s" and substitute() strpart() get part of a string using byte index strcharpart() get part of a string using char index + slice() take a slice of a string, using char index in + Vim9 script strgetchar() get character from a string using char index expand() expand special keywords expandcmd() expand a command like done for `:edit` @@ -659,6 +661,7 @@ List manipulation: *list-functions* filter() remove selected items from a List map() change each List item reduce() reduce a List to a value + slice() take a slice of a List sort() sort a List reverse() reverse the order of a List or Blob uniq() remove copies of repeated adjacent items |