summaryrefslogtreecommitdiff
path: root/runtime/doc/eval.txt
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/doc/eval.txt')
-rw-r--r--runtime/doc/eval.txt60
1 files changed, 40 insertions, 20 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 2d7beb7c2..3e9985843 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -1,4 +1,4 @@
-*eval.txt* For Vim version 7.4. Last change: 2016 Apr 14
+*eval.txt* For Vim version 7.4. Last change: 2016 Apr 20
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -752,7 +752,7 @@ A |Dictionary| can only be compared with a |Dictionary| and only "equal", "not
equal" and "is" can be used. This compares the key/values of the |Dictionary|
recursively. Ignoring case means case is ignored when comparing item values.
- *E693* *E694*
+ *E694*
A |Funcref| can only be compared with a |Funcref| and only "equal" and "not
equal" can be used. Case is never ignored. Whether arguments or a Dictionary
are 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}
str2float({expr}) Float convert String to Float
str2nr({expr} [, {base}]) Number convert String to Number
strchars({expr} [, {skipcc}]) Number character length of the String {expr}
+strcharpart({str}, {start}[, {len}])
+ String {len} characters of {str} at {start}
strdisplaywidth({expr} [, {col}]) Number display length of the String {expr}
strftime({format}[, {time}]) String time in specified format
+strgetchar({str}, {index}) Number get char {index} from {str}
stridx({haystack}, {needle}[, {start}])
Number index of {needle} in {haystack}
string({expr}) String String representation of {expr} value
strlen({expr}) Number length of the String {expr}
-strpart({src}, {start}[, {len}])
- String {len} characters of {src} at {start}
+strpart({str}, {start}[, {len}])
+ String {len} characters of {str} at {start}
strridx({haystack}, {needle} [, {start}])
Number last index of {needle} in {haystack}
strtrans({expr}) String translate string to make it printable
@@ -2551,7 +2554,9 @@ byteidx({expr}, {nr}) *byteidx()*
same: >
let s = strpart(str, byteidx(str, 3))
echo strpart(s, 0, byteidx(s, 1))
-< If there are less than {nr} characters -1 is returned.
+< Also see |strgetchar()| and |strcharpart()|.
+
+ If there are less than {nr} characters -1 is returned.
If there are exactly {nr} characters the length of the string
in bytes is returned.
@@ -3418,6 +3423,10 @@ feedkeys({string} [, {mode}]) *feedkeys()*
will behave as if <Esc> is typed, to avoid getting
stuck, waiting for a character to be typed before the
script continues.
+ '!' When used with 'x' will not end Insert mode. Can be
+ used in a test when a timer is set to exit Insert mode
+ a little later. Useful for testing CursorHoldI.
+
Return value is always 0.
filereadable({file}) *filereadable()*
@@ -4100,16 +4109,21 @@ getreg([{regname} [, 1 [, {list}]]]) *getreg()*
The result is a String, which is the contents of register
{regname}. Example: >
:let cliptext = getreg('*')
-< getreg('=') returns the last evaluated value of the expression
+< When {regname} was not set the result is a empty string.
+
+ getreg('=') returns the last evaluated value of the expression
register. (For use in maps.)
getreg('=', 1) returns the expression itself, so that it can
be restored with |setreg()|. For other registers the extra
argument is ignored, thus you can always give it.
- If {list} is present and non-zero result type is changed to
- |List|. Each list item is one text line. Use it if you care
+
+ If {list} is present and non-zero, the result type is changed
+ to |List|. Each list item is one text line. Use it if you care
about zero bytes possibly present inside register: without
third argument both NLs and zero bytes are represented as NLs
(see |NL-used-for-Nul|).
+ When the register was not set an empty list is returned.
+
If {regname} is not specified, |v:register| is used.
@@ -5590,7 +5604,6 @@ pumvisible() *pumvisible()*
This can be used to avoid some things that would remove the
popup menu.
- *E860*
py3eval({expr}) *py3eval()*
Evaluate Python expression {expr} and return its result
converted to Vim data structures.
@@ -6652,7 +6665,6 @@ strchars({expr} [, {skipcc}]) *strchars()*
counted separately.
When {skipcc} set to 1, Composing characters are ignored.
Also see |strlen()|, |strdisplaywidth()| and |strwidth()|.
-
{skipcc} is only available after 7.4.755. For backward
compatibility, you can define a wrapper function: >
@@ -6670,6 +6682,13 @@ strchars({expr} [, {skipcc}]) *strchars()*
endfunction
endif
<
+strcharpart({src}, {start}[, {len}]) *strcharpart()*
+ Like |strpart()| but using character index and length instead
+ of byte index and length.
+ When a character index is used where a character does not
+ exist it is assumed to be one byte. For example: >
+ strcharpart('abc', -1, 2)
+< results in 'a'.
strdisplaywidth({expr}[, {col}]) *strdisplaywidth()*
The result is a Number, which is the number of display cells
@@ -6703,6 +6722,12 @@ strftime({format} [, {time}]) *strftime()*
< Not available on all systems. To check use: >
:if exists("*strftime")
+strgetchar({str}, {index}) *strgetchar()*
+ Get character {index} from {str}. This uses a character
+ index, not a byte index. Composing characters are considered
+ separate characters here.
+ Also see |strcharpart()| and |strchars()|.
+
stridx({haystack}, {needle} [, {start}]) *stridx()*
The result is a Number, which gives the byte index in
{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
strpart({src}, {start}[, {len}]) *strpart()*
The result is a String, which is part of {src}, starting from
byte {start}, with the byte length {len}.
- When non-existing bytes are included, this doesn't result in
- an error, the bytes are simply omitted.
+ To count characters instead of bytes use |strcharpart()|.
+
+ When bytes are selected which do not exist, this doesn't
+ result in an error, the bytes are simply omitted.
If {len} is missing, the copy continues from {start} till the
end of the {src}. >
strpart("abcdefg", 3, 2) == "de"
strpart("abcdefg", -2, 4) == "ab"
strpart("abcdefg", 5, 4) == "fg"
strpart("abcdefg", 3) == "defg"
+
< Note: To get the first character, {start} must be 0. For
example, to get three bytes under and after the cursor: >
strpart(getline("."), col(".") - 1, 3)
@@ -8422,14 +8450,6 @@ This does NOT work: >
endfor
< Note that reordering the list (e.g., with sort() or
reverse()) may have unexpected effects.
- Note that the type of each list item should be
- identical to avoid errors for the type of {var}
- changing. Unlet the variable at the end of the loop
- to allow multiple item types: >
- for item in ["foo", ["bar"]]
- echo item
- unlet item " E706 without this
- endfor
:for [{var1}, {var2}, ...] in {listlist}
:endfo[r]