1- *eval.txt* For Vim version 8.2. Last change: 2021 Feb 10
1+ *eval.txt* For Vim version 8.2. Last change: 2021 Mar 10
22
33
44 VIM REFERENCE MANUAL by Bram Moolenaar
@@ -1187,7 +1187,8 @@ byte under the cursor: >
11871187
11881188In Vim9 script:
11891189If expr8 is a String this results in a String that contains the expr1'th
1190- single character from expr8. To use byte indexes use |strpart()|.
1190+ single character (including any composing characters) from expr8. To use byte
1191+ indexes use |strpart()|.
11911192
11921193Index zero gives the first byte or character. Careful: text column numbers
11931194start with one!
@@ -1217,8 +1218,9 @@ In legacy Vim script the indexes are byte indexes. This doesn't recognize
12171218multibyte encodings, see |byteidx()| for computing the indexes. If expr8 is
12181219a Number it is first converted to a String.
12191220
1220- In Vim9 script the indexes are character indexes. To use byte indexes use
1221- |strpart()|.
1221+ In Vim9 script the indexes are character indexes and include composing
1222+ characters. To use byte indexes use |strpart()|. To use character indexes
1223+ without including composing characters use |strcharpart()|.
12221224
12231225The item at index expr1b is included, it is inclusive. For an exclusive index
12241226use the |slice()| function.
@@ -2935,10 +2937,11 @@ str2list({expr} [, {utf8}]) List convert each character of {expr} to
29352937 ASCII/UTF8 value
29362938str2nr({expr} [, {base} [, {quoted}]])
29372939 Number convert String to Number
2938- strcharpart({str}, {start} [, {len}])
2940+ strcharlen({expr}) Number character length of the String {expr}
2941+ strcharpart({str}, {start} [, {len} [, {skipcc}]])
29392942 String {len} characters of {str} at
29402943 character {start}
2941- strchars({expr} [, {skipcc}]) Number character length of the String {expr}
2944+ strchars({expr} [, {skipcc}]) Number character count of the String {expr}
29422945strdisplaywidth({expr} [, {col}]) Number display length of the String {expr}
29432946strftime({format} [, {time}]) String format time with a specified format
29442947strgetchar({str}, {index}) Number get char {index} from {str}
@@ -5312,6 +5315,9 @@ getcharpos({expr})
53125315 Get the position for {expr}. Same as |getpos()| but the column
53135316 number in the returned List is a character index instead of
53145317 a byte index.
5318+ If |getpos()| returns a very large column number, such as
5319+ 2147483647, then getcharpos() will return the character index
5320+ of the last character.
53155321
53165322 Example:
53175323 With the cursor on '세' in line 5 with text "여보세요": >
@@ -5791,6 +5797,8 @@ getpos({expr}) Get the position for {expr}. For possible values of {expr}
57915797 The column number in the returned List is the byte position
57925798 within the line. To get the character position in the line,
57935799 use |getcharpos()|
5800+ The column number can be very large, e.g. 2147483647, in which
5801+ case it means "after the end of the line".
57945802 This can be used to save and restore the position of a mark: >
57955803 let save_a_mark = getpos("'a")
57965804 ...
@@ -7462,7 +7470,8 @@ matchaddpos({group}, {pos} [, {priority} [, {id} [, {dict}]]])
74627470 to be used when fast match additions and deletions are
74637471 required, for example to highlight matching parentheses.
74647472
7465- The list {pos} can contain one of these items:
7473+ {pos} is a list of positions. Each position can be one of
7474+ these:
74667475 - A number. This whole line will be highlighted. The first
74677476 line has number 1.
74687477 - A list with one number, e.g., [23]. The whole line with this
@@ -7475,7 +7484,7 @@ matchaddpos({group}, {pos} [, {priority} [, {id} [, {dict}]]])
74757484 - A list with three numbers, e.g., [23, 11, 3]. As above, but
74767485 the third number gives the length of the highlight in bytes.
74777486
7478- The maximum number of positions is 8.
7487+ The maximum number of positions in {pos} is 8.
74797488
74807489 Example: >
74817490 :highlight MyGroup ctermbg=green guibg=green
@@ -7484,8 +7493,7 @@ matchaddpos({group}, {pos} [, {priority} [, {id} [, {dict}]]])
74847493 :call matchdelete(m)
74857494
74867495< Matches added by |matchaddpos()| are returned by
7487- |getmatches()| with an entry "pos1", "pos2", etc., with the
7488- value a list like the {pos} item.
7496+ |getmatches()|.
74897497
74907498 Can also be used as a |method|: >
74917499 GetGroup()->matchaddpos([23, 11])
@@ -9925,7 +9933,7 @@ slice({expr}, {start} [, {end}]) *slice()*
99259933 Similar to using a |slice| "expr[start : end]", but "end" is
99269934 used exclusive. And for a string the indexes are used as
99279935 character indexes instead of byte indexes, like in
9928- |vim9script|.
9936+ |vim9script|. Also, composing characters are not counted.
99299937 When {end} is omitted the slice continues to the last item.
99309938 When {end} is -1 the last item is omitted.
99319939
@@ -10283,23 +10291,44 @@ str2nr({expr} [, {base} [, {quoted}]]) *str2nr()*
1028310291 Can also be used as a |method|: >
1028410292 GetText()->str2nr()
1028510293
10286- strcharpart({src}, {start} [, {len}]) *strcharpart()*
10294+
10295+ strcharlen({expr}) *strcharlen()*
10296+ The result is a Number, which is the number of characters
10297+ in String {expr}. Composing characters are ignored.
10298+ |strchars()| can count the number of characters, counting
10299+ composing characters separately.
10300+
10301+ Also see |strlen()|, |strdisplaywidth()| and |strwidth()|.
10302+
10303+ Can also be used as a |method|: >
10304+ GetText()->strcharlen()
10305+
10306+
10307+ strcharpart({src}, {start} [, {len} [, {skipcc}]]) *strcharpart()*
1028710308 Like |strpart()| but using character index and length instead
1028810309 of byte index and length.
10310+ When {skipcc} is omitted or zero, composing characters are
10311+ counted separately.
10312+ When {skipcc} set to 1, Composing characters are ignored,
10313+ similar to |slice()|.
1028910314 When a character index is used where a character does not
10290- exist it is assumed to be one character. For example: >
10315+ exist it is omitted and counted as one character. For
10316+ example: >
1029110317 strcharpart('abc', -1, 2)
1029210318< results in 'a'.
1029310319
1029410320 Can also be used as a |method|: >
1029510321 GetText()->strcharpart(5)
1029610322
10323+
1029710324strchars({expr} [, {skipcc}]) *strchars()*
1029810325 The result is a Number, which is the number of characters
1029910326 in String {expr}.
1030010327 When {skipcc} is omitted or zero, composing characters are
1030110328 counted separately.
1030210329 When {skipcc} set to 1, Composing characters are ignored.
10330+ |strcharlen()| always does this.
10331+
1030310332 Also see |strlen()|, |strdisplaywidth()| and |strwidth()|.
1030410333
1030510334 {skipcc} is only available after 7.4.755. For backward
@@ -13159,7 +13188,7 @@ text...
1315913188 Cannot be followed by a comment.
1316013189 Examples: >
1316113190 :execute "buffer" nextbuf
13162- :execute "normal" count . "w"
13191+ :execute "normal" count .. "w"
1316313192<
1316413193 ":execute" can be used to append a command to commands
1316513194 that don't accept a '|'. Example: >
@@ -13175,8 +13204,8 @@ text...
1317513204 file names. The |fnameescape()| function can be used
1317613205 for Vim commands, |shellescape()| for |:!| commands.
1317713206 Examples: >
13178- :execute "e " . fnameescape(filename)
13179- :execute "!ls " . shellescape(filename, 1)
13207+ :execute "e " .. fnameescape(filename)
13208+ :execute "!ls " .. shellescape(filename, 1)
1318013209<
1318113210 Note: The executed string may be any command-line, but
1318213211 starting or ending "if", "while" and "for" does not
0 commit comments