comparison runtime/doc/eval.txt @ 8951:0bdeaf7092bc

commit https://github.com/vim/vim/commit/aa3b15dbebf333282503d6031e2f9ba6ee4398ed Author: Bram Moolenaar <Bram@vim.org> Date: Thu Apr 21 08:53:19 2016 +0200 Updated runtime files.
author Christian Brabandt <cb@256bit.org>
date Thu, 21 Apr 2016 09:00:08 +0200
parents b7de875169e6
children 34c45ee4210d
comparison
equal deleted inserted replaced
8950:4112e9a27a93 8951:0bdeaf7092bc
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
2 2
3 3
4 VIM REFERENCE MANUAL by Bram Moolenaar 4 VIM REFERENCE MANUAL by Bram Moolenaar
5 5
6 6
750 *E735* *E736* 750 *E735* *E736*
751 A |Dictionary| can only be compared with a |Dictionary| and only "equal", "not 751 A |Dictionary| can only be compared with a |Dictionary| and only "equal", "not
752 equal" and "is" can be used. This compares the key/values of the |Dictionary| 752 equal" and "is" can be used. This compares the key/values of the |Dictionary|
753 recursively. Ignoring case means case is ignored when comparing item values. 753 recursively. Ignoring case means case is ignored when comparing item values.
754 754
755 *E693* *E694* 755 *E694*
756 A |Funcref| can only be compared with a |Funcref| and only "equal" and "not 756 A |Funcref| can only be compared with a |Funcref| and only "equal" and "not
757 equal" can be used. Case is never ignored. Whether arguments or a Dictionary 757 equal" can be used. Case is never ignored. Whether arguments or a Dictionary
758 are bound (with a partial) is ignored. This is so that when a function is 758 are bound (with a partial) is ignored. This is so that when a function is
759 made a member of a Dictionary it is still considered to be the same function. 759 made a member of a Dictionary it is still considered to be the same function.
760 To compare partials to see if they bind the same argument and Dictionary 760 To compare partials to see if they bind the same argument and Dictionary
2125 List make |List| from {pat} separated {expr} 2125 List make |List| from {pat} separated {expr}
2126 sqrt({expr}) Float square root of {expr} 2126 sqrt({expr}) Float square root of {expr}
2127 str2float({expr}) Float convert String to Float 2127 str2float({expr}) Float convert String to Float
2128 str2nr({expr} [, {base}]) Number convert String to Number 2128 str2nr({expr} [, {base}]) Number convert String to Number
2129 strchars({expr} [, {skipcc}]) Number character length of the String {expr} 2129 strchars({expr} [, {skipcc}]) Number character length of the String {expr}
2130 strcharpart({str}, {start}[, {len}])
2131 String {len} characters of {str} at {start}
2130 strdisplaywidth({expr} [, {col}]) Number display length of the String {expr} 2132 strdisplaywidth({expr} [, {col}]) Number display length of the String {expr}
2131 strftime({format}[, {time}]) String time in specified format 2133 strftime({format}[, {time}]) String time in specified format
2134 strgetchar({str}, {index}) Number get char {index} from {str}
2132 stridx({haystack}, {needle}[, {start}]) 2135 stridx({haystack}, {needle}[, {start}])
2133 Number index of {needle} in {haystack} 2136 Number index of {needle} in {haystack}
2134 string({expr}) String String representation of {expr} value 2137 string({expr}) String String representation of {expr} value
2135 strlen({expr}) Number length of the String {expr} 2138 strlen({expr}) Number length of the String {expr}
2136 strpart({src}, {start}[, {len}]) 2139 strpart({str}, {start}[, {len}])
2137 String {len} characters of {src} at {start} 2140 String {len} characters of {str} at {start}
2138 strridx({haystack}, {needle} [, {start}]) 2141 strridx({haystack}, {needle} [, {start}])
2139 Number last index of {needle} in {haystack} 2142 Number last index of {needle} in {haystack}
2140 strtrans({expr}) String translate string to make it printable 2143 strtrans({expr}) String translate string to make it printable
2141 strwidth({expr}) Number display cell length of the String {expr} 2144 strwidth({expr}) Number display cell length of the String {expr}
2142 submatch({nr}[, {list}]) String or List 2145 submatch({nr}[, {list}]) String or List
2549 echo matchstr(str, ".", byteidx(str, 3)) 2552 echo matchstr(str, ".", byteidx(str, 3))
2550 < will display the fourth character. Another way to do the 2553 < will display the fourth character. Another way to do the
2551 same: > 2554 same: >
2552 let s = strpart(str, byteidx(str, 3)) 2555 let s = strpart(str, byteidx(str, 3))
2553 echo strpart(s, 0, byteidx(s, 1)) 2556 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.
2555 If there are exactly {nr} characters the length of the string 2560 If there are exactly {nr} characters the length of the string
2556 in bytes is returned. 2561 in bytes is returned.
2557 2562
2558 byteidxcomp({expr}, {nr}) *byteidxcomp()* 2563 byteidxcomp({expr}, {nr}) *byteidxcomp()*
2559 Like byteidx(), except that a composing character is counted 2564 Like byteidx(), except that a composing character is counted
3416 (possibly with an empty {string}) to execute all the 3421 (possibly with an empty {string}) to execute all the
3417 typeahead. Note that when Vim ends in Insert mode it 3422 typeahead. Note that when Vim ends in Insert mode it
3418 will behave as if <Esc> is typed, to avoid getting 3423 will behave as if <Esc> is typed, to avoid getting
3419 stuck, waiting for a character to be typed before the 3424 stuck, waiting for a character to be typed before the
3420 script continues. 3425 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
3421 Return value is always 0. 3430 Return value is always 0.
3422 3431
3423 filereadable({file}) *filereadable()* 3432 filereadable({file}) *filereadable()*
3424 The result is a Number, which is TRUE when a file with the 3433 The result is a Number, which is TRUE when a file with the
3425 name {file} exists, and can be read. If {file} doesn't exist, 3434 name {file} exists, and can be read. If {file} doesn't exist,
4098 4107
4099 getreg([{regname} [, 1 [, {list}]]]) *getreg()* 4108 getreg([{regname} [, 1 [, {list}]]]) *getreg()*
4100 The result is a String, which is the contents of register 4109 The result is a String, which is the contents of register
4101 {regname}. Example: > 4110 {regname}. Example: >
4102 :let cliptext = getreg('*') 4111 :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
4104 register. (For use in maps.) 4115 register. (For use in maps.)
4105 getreg('=', 1) returns the expression itself, so that it can 4116 getreg('=', 1) returns the expression itself, so that it can
4106 be restored with |setreg()|. For other registers the extra 4117 be restored with |setreg()|. For other registers the extra
4107 argument is ignored, thus you can always give it. 4118 argument is ignored, thus you can always give it.
4108 If {list} is present and non-zero result type is changed to 4119
4109 |List|. Each list item is one text line. Use it if you care 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
4110 about zero bytes possibly present inside register: without 4122 about zero bytes possibly present inside register: without
4111 third argument both NLs and zero bytes are represented as NLs 4123 third argument both NLs and zero bytes are represented as NLs
4112 (see |NL-used-for-Nul|). 4124 (see |NL-used-for-Nul|).
4125 When the register was not set an empty list is returned.
4126
4113 If {regname} is not specified, |v:register| is used. 4127 If {regname} is not specified, |v:register| is used.
4114 4128
4115 4129
4116 getregtype([{regname}]) *getregtype()* 4130 getregtype([{regname}]) *getregtype()*
4117 The result is a String, which is type of register {regname}. 4131 The result is a String, which is type of register {regname}.
5588 Returns non-zero when the popup menu is visible, zero 5602 Returns non-zero when the popup menu is visible, zero
5589 otherwise. See |ins-completion-menu|. 5603 otherwise. See |ins-completion-menu|.
5590 This can be used to avoid some things that would remove the 5604 This can be used to avoid some things that would remove the
5591 popup menu. 5605 popup menu.
5592 5606
5593 *E860*
5594 py3eval({expr}) *py3eval()* 5607 py3eval({expr}) *py3eval()*
5595 Evaluate Python expression {expr} and return its result 5608 Evaluate Python expression {expr} and return its result
5596 converted to Vim data structures. 5609 converted to Vim data structures.
5597 Numbers and strings are returned as they are (strings are 5610 Numbers and strings are returned as they are (strings are
5598 copied though, Unicode strings are additionally converted to 5611 copied though, Unicode strings are additionally converted to
6650 in String {expr}. 6663 in String {expr}.
6651 When {skipcc} is omitted or zero, composing characters are 6664 When {skipcc} is omitted or zero, composing characters are
6652 counted separately. 6665 counted separately.
6653 When {skipcc} set to 1, Composing characters are ignored. 6666 When {skipcc} set to 1, Composing characters are ignored.
6654 Also see |strlen()|, |strdisplaywidth()| and |strwidth()|. 6667 Also see |strlen()|, |strdisplaywidth()| and |strwidth()|.
6655
6656 6668
6657 {skipcc} is only available after 7.4.755. For backward 6669 {skipcc} is only available after 7.4.755. For backward
6658 compatibility, you can define a wrapper function: > 6670 compatibility, you can define a wrapper function: >
6659 if has("patch-7.4.755") 6671 if has("patch-7.4.755")
6660 function s:strchars(str, skipcc) 6672 function s:strchars(str, skipcc)
6668 return strchars(a:str) 6680 return strchars(a:str)
6669 endif 6681 endif
6670 endfunction 6682 endfunction
6671 endif 6683 endif
6672 < 6684 <
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'.
6673 6692
6674 strdisplaywidth({expr}[, {col}]) *strdisplaywidth()* 6693 strdisplaywidth({expr}[, {col}]) *strdisplaywidth()*
6675 The result is a Number, which is the number of display cells 6694 The result is a Number, which is the number of display cells
6676 String {expr} occupies on the screen when it starts at {col}. 6695 String {expr} occupies on the screen when it starts at {col}.
6677 When {col} is omitted zero is used. Otherwise it is the 6696 When {col} is omitted zero is used. Otherwise it is the
6701 :echo strftime("%c", getftime("file.c")) 6720 :echo strftime("%c", getftime("file.c"))
6702 Show mod time of file.c. 6721 Show mod time of file.c.
6703 < Not available on all systems. To check use: > 6722 < Not available on all systems. To check use: >
6704 :if exists("*strftime") 6723 :if exists("*strftime")
6705 6724
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
6706 stridx({haystack}, {needle} [, {start}]) *stridx()* 6731 stridx({haystack}, {needle} [, {start}]) *stridx()*
6707 The result is a Number, which gives the byte index in 6732 The result is a Number, which gives the byte index in
6708 {haystack} of the first occurrence of the String {needle}. 6733 {haystack} of the first occurrence of the String {needle}.
6709 If {start} is specified, the search starts at index {start}. 6734 If {start} is specified, the search starts at index {start}.
6710 This can be used to find a second match: > 6735 This can be used to find a second match: >
6750 Also see |len()|, |strdisplaywidth()| and |strwidth()|. 6775 Also see |len()|, |strdisplaywidth()| and |strwidth()|.
6751 6776
6752 strpart({src}, {start}[, {len}]) *strpart()* 6777 strpart({src}, {start}[, {len}]) *strpart()*
6753 The result is a String, which is part of {src}, starting from 6778 The result is a String, which is part of {src}, starting from
6754 byte {start}, with the byte length {len}. 6779 byte {start}, with the byte length {len}.
6755 When non-existing bytes are included, this doesn't result in 6780 To count characters instead of bytes use |strcharpart()|.
6756 an error, the bytes are simply omitted. 6781
6782 When bytes are selected which do not exist, this doesn't
6783 result in an error, the bytes are simply omitted.
6757 If {len} is missing, the copy continues from {start} till the 6784 If {len} is missing, the copy continues from {start} till the
6758 end of the {src}. > 6785 end of the {src}. >
6759 strpart("abcdefg", 3, 2) == "de" 6786 strpart("abcdefg", 3, 2) == "de"
6760 strpart("abcdefg", -2, 4) == "ab" 6787 strpart("abcdefg", -2, 4) == "ab"
6761 strpart("abcdefg", 5, 4) == "fg" 6788 strpart("abcdefg", 5, 4) == "fg"
6762 strpart("abcdefg", 3) == "defg" 6789 strpart("abcdefg", 3) == "defg"
6790
6763 < Note: To get the first character, {start} must be 0. For 6791 < Note: To get the first character, {start} must be 0. For
6764 example, to get three bytes under and after the cursor: > 6792 example, to get three bytes under and after the cursor: >
6765 strpart(getline("."), col(".") - 1, 3) 6793 strpart(getline("."), col(".") - 1, 3)
6766 < 6794 <
6767 strridx({haystack}, {needle} [, {start}]) *strridx()* 6795 strridx({haystack}, {needle} [, {start}]) *strridx()*
8420 for item in mylist 8448 for item in mylist
8421 call remove(mylist, 0) 8449 call remove(mylist, 0)
8422 endfor 8450 endfor
8423 < Note that reordering the list (e.g., with sort() or 8451 < Note that reordering the list (e.g., with sort() or
8424 reverse()) may have unexpected effects. 8452 reverse()) may have unexpected effects.
8425 Note that the type of each list item should be
8426 identical to avoid errors for the type of {var}
8427 changing. Unlet the variable at the end of the loop
8428 to allow multiple item types: >
8429 for item in ["foo", ["bar"]]
8430 echo item
8431 unlet item " E706 without this
8432 endfor
8433 8453
8434 :for [{var1}, {var2}, ...] in {listlist} 8454 :for [{var1}, {var2}, ...] in {listlist}
8435 :endfo[r] 8455 :endfo[r]
8436 Like ":for" above, but each item in {listlist} must be 8456 Like ":for" above, but each item in {listlist} must be
8437 a list, of which each item is assigned to {var1}, 8457 a list, of which each item is assigned to {var1},