1- *eval.txt* For Vim version 7.4. Last change: 2016 Apr 14
1+ *eval.txt* For Vim version 7.4. Last change: 2016 Apr 20
22
33
44 VIM REFERENCE MANUAL by Bram Moolenaar
@@ -752,7 +752,7 @@ A |Dictionary| can only be compared with a |Dictionary| and only "equal", "not
752752equal" and "is" can be used. This compares the key/values of the | Dictionary |
753753recursively. Ignoring case means case is ignored when comparing item values.
754754
755- *E693* * E694*
755+ *E694*
756756A | Funcref | can only be compared with a | Funcref | and only "equal" and "not
757757equal" can be used. Case is never ignored. Whether arguments or a Dictionary
758758are bound (with a partial) is ignored. This is so that when a function is
@@ -2127,14 +2127,17 @@ sqrt({expr}) Float square root of {expr}
21272127str2float({expr} ) Float convert String to Float
21282128str2nr({expr} [, {base} ]) Number convert String to Number
21292129strchars({expr} [, {skipcc} ]) Number character length of the String {expr}
2130+ strcharpart({str} , {start} [, {len} ])
2131+ String {len} characters of {str} at {start}
21302132strdisplaywidth({expr} [, {col} ]) Number display length of the String {expr}
21312133strftime({format} [, {time} ]) String time in specified format
2134+ strgetchar({str} , {index} ) Number get char {index} from {str}
21322135stridx({haystack} , {needle} [, {start} ])
21332136 Number index of {needle} in {haystack}
21342137string({expr} ) String String representation of {expr} value
21352138strlen({expr} ) Number length of the String {expr}
2136- strpart({src } , {start} [, {len} ])
2137- String {len} characters of {src } at {start}
2139+ strpart({str } , {start} [, {len} ])
2140+ String {len} characters of {str } at {start}
21382141strridx({haystack} , {needle} [, {start} ])
21392142 Number last index of {needle} in {haystack}
21402143strtrans({expr} ) String translate string to make it printable
@@ -2551,7 +2554,9 @@ byteidx({expr}, {nr}) *byteidx()*
25512554 same: >
25522555 let s = strpart(str, byteidx(str, 3))
25532556 echo strpart(s, 0, byteidx(s, 1))
2554- < If there are less than {nr} characters -1 is returned.
2557+ < Also see | strgetchar() | and | strcharpart() | .
2558+
2559+ If there are less than {nr} characters -1 is returned.
25552560 If there are exactly {nr} characters the length of the string
25562561 in bytes is returned.
25572562
@@ -3418,6 +3423,10 @@ feedkeys({string} [, {mode}]) *feedkeys()*
34183423 will behave as if <Esc> is typed, to avoid getting
34193424 stuck, waiting for a character to be typed before the
34203425 script continues.
3426+ '!' When used with 'x' will not end Insert mode. Can be
3427+ used in a test when a timer is set to exit Insert mode
3428+ a little later. Useful for testing CursorHoldI.
3429+
34213430 Return value is always 0.
34223431
34233432filereadable({file} ) *filereadable()*
@@ -4100,16 +4109,21 @@ getreg([{regname} [, 1 [, {list}]]]) *getreg()*
41004109 The result is a String, which is the contents of register
41014110 {regname} . Example: >
41024111 :let cliptext = getreg('*')
4103- < getreg('=') returns the last evaluated value of the expression
4112+ < When {regname} was not set the result is a empty string.
4113+
4114+ getreg('=') returns the last evaluated value of the expression
41044115 register. (For use in maps.)
41054116 getreg('=', 1) returns the expression itself, so that it can
41064117 be restored with | setreg() | . For other registers the extra
41074118 argument is ignored, thus you can always give it.
4108- If {list} is present and non-zero result type is changed to
4109- | List | . Each list item is one text line. Use it if you care
4119+
4120+ If {list} is present and non-zero, the result type is changed
4121+ to | List | . Each list item is one text line. Use it if you care
41104122 about zero bytes possibly present inside register: without
41114123 third argument both NLs and zero bytes are represented as NLs
41124124 (see | NL-used-for-Nul | ).
4125+ When the register was not set an empty list is returned.
4126+
41134127 If {regname} is not specified, | v:register | is used.
41144128
41154129
@@ -5590,7 +5604,6 @@ pumvisible() *pumvisible()*
55905604 This can be used to avoid some things that would remove the
55915605 popup menu.
55925606
5593- *E860*
55945607py3eval({expr} ) *py3eval()*
55955608 Evaluate Python expression {expr} and return its result
55965609 converted to Vim data structures.
@@ -6652,7 +6665,6 @@ strchars({expr} [, {skipcc}]) *strchars()*
66526665 counted separately.
66536666 When {skipcc} set to 1, Composing characters are ignored.
66546667 Also see | strlen() | , | strdisplaywidth() | and | strwidth() | .
6655-
66566668
66576669 {skipcc} is only available after 7.4.755. For backward
66586670 compatibility, you can define a wrapper function: >
@@ -6670,6 +6682,13 @@ strchars({expr} [, {skipcc}]) *strchars()*
66706682 endfunction
66716683 endif
66726684<
6685+ strcharpart({src} , {start} [, {len} ]) *strcharpart()*
6686+ Like | strpart() | but using character index and length instead
6687+ of byte index and length.
6688+ When a character index is used where a character does not
6689+ exist it is assumed to be one byte. For example: >
6690+ strcharpart('abc', -1, 2)
6691+ < results in 'a'.
66736692
66746693strdisplaywidth({expr} [, {col} ]) *strdisplaywidth()*
66756694 The result is a Number, which is the number of display cells
@@ -6703,6 +6722,12 @@ strftime({format} [, {time}]) *strftime()*
67036722< Not available on all systems. To check use: >
67046723 :if exists("*strftime")
67056724
6725+ strgetchar({str} , {index} ) *strgetchar()*
6726+ Get character {index} from {str} . This uses a character
6727+ index, not a byte index. Composing characters are considered
6728+ separate characters here.
6729+ Also see | strcharpart() | and | strchars() | .
6730+
67066731stridx({haystack} , {needle} [, {start} ]) *stridx()*
67076732 The result is a Number, which gives the byte index in
67086733 {haystack} of the first occurrence of the String {needle} .
@@ -6752,14 +6777,17 @@ strlen({expr}) The result is a Number, which is the length of the String
67526777strpart({src} , {start} [, {len} ]) *strpart()*
67536778 The result is a String, which is part of {src} , starting from
67546779 byte {start} , with the byte length {len} .
6755- When non-existing bytes are included, this doesn't result in
6756- an error, the bytes are simply omitted.
6780+ To count characters instead of bytes use | strcharpart() | .
6781+
6782+ When bytes are selected which do not exist, this doesn't
6783+ result in an error, the bytes are simply omitted.
67576784 If {len} is missing, the copy continues from {start} till the
67586785 end of the {src} . >
67596786 strpart("abcdefg", 3, 2) == "de"
67606787 strpart("abcdefg", -2, 4) == "ab"
67616788 strpart("abcdefg", 5, 4) == "fg"
67626789 strpart("abcdefg", 3) == "defg"
6790+
67636791< Note: To get the first character, {start} must be 0. For
67646792 example, to get three bytes under and after the cursor: >
67656793 strpart(getline("."), col(".") - 1, 3)
@@ -8426,14 +8454,6 @@ This does NOT work: >
84268454 endfor
84278455< Note that reordering the list (e.g., with sort() or
84288456 reverse()) may have unexpected effects.
8429- Note that the type of each list item should be
8430- identical to avoid errors for the type of {var}
8431- changing. Unlet the variable at the end of the loop
8432- to allow multiple item types: >
8433- for item in ["foo", ["bar"]]
8434- echo item
8435- unlet item " E706 without this
8436- endfor
84378457
84388458:for [{var1} , {var2} , ...] in {listlist}
84398459:endfo[r]
0 commit comments