comparison runtime/doc/eval.txt @ 119:e8f07016e34d

updated for version 7.0042
author vimboss
date Wed, 19 Jan 2005 22:18:32 +0000
parents f6e567606d47
children f67f8a8d81ba
comparison
equal deleted inserted replaced
118:45fd0ec37cf3 119:e8f07016e34d
1 *eval.txt* For Vim version 7.0aa. Last change: 2005 Jan 17 1 *eval.txt* For Vim version 7.0aa. Last change: 2005 Jan 19
2 2
3 3
4 VIM REFERENCE MANUAL by Bram Moolenaar 4 VIM REFERENCE MANUAL by Bram Moolenaar
5 5
6 6
116 A Funcref can also be used with the |:call| command: > 116 A Funcref can also be used with the |:call| command: >
117 :call Fn() 117 :call Fn()
118 :call dict.init() 118 :call dict.init()
119 119
120 The name of the referenced function can be obtained with |string()|. > 120 The name of the referenced function can be obtained with |string()|. >
121 :let func = string(Myfunc) 121 :let func = string(Fn)
122 122
123 You can use |call()| to invoke a Funcref and use a list variable for the 123 You can use |call()| to invoke a Funcref and use a list variable for the
124 arguments: > 124 arguments: >
125 :let r = call(Myfunc, mylist) 125 :let r = call(Fn, mylist)
126 126
127 127
128 1.3 Lists ~ 128 1.3 Lists ~
129 *List* *E686* 129 *List* *E686*
130 A List is an ordered sequence of items. An item can be of any type. Items 130 A List is an ordered sequence of items. An item can be of any type. Items
168 168
169 List concatenation ~ 169 List concatenation ~
170 170
171 Two lists can be concatenated with the "+" operator: > 171 Two lists can be concatenated with the "+" operator: >
172 :let longlist = mylist + [5, 6] 172 :let longlist = mylist + [5, 6]
173 :let mylist += [7, 8]
173 174
174 To prepend or append an item turn the item into a list by putting [] around 175 To prepend or append an item turn the item into a list by putting [] around
175 it. To change a list in-place see |list-modification| below. 176 it. To change a list in-place see |list-modification| below.
176 177
177 178
437 438
438 Merging a Dictionary with another is done with |extend()|: > 439 Merging a Dictionary with another is done with |extend()|: >
439 :call extend(adict, bdict) 440 :call extend(adict, bdict)
440 This extends adict with all entries from bdict. Duplicate keys cause entries 441 This extends adict with all entries from bdict. Duplicate keys cause entries
441 in adict to be overwritten. An optional third argument can change this. 442 in adict to be overwritten. An optional third argument can change this.
443 Note that the order of entries in a Dictionary is irrelevant, thus don't
444 expect ":echo adict" to show the items from bdict after the older entries in
445 adict.
442 446
443 Weeding out entries from a Dictionary can be done with |filter()|: > 447 Weeding out entries from a Dictionary can be done with |filter()|: >
444 :call filter(dict 'v:val =~ "x"') 448 :call filter(dict 'v:val =~ "x"')
445 This removes all entries from "dict" with a value not matching 'x'. 449 This removes all entries from "dict" with a value not matching 'x'.
446 450
2117 Add all entries from {expr2} to {expr1}. 2121 Add all entries from {expr2} to {expr1}.
2118 If a key exists in both {expr1} and {expr2} then {expr3} is 2122 If a key exists in both {expr1} and {expr2} then {expr3} is
2119 used to decide what to do: 2123 used to decide what to do:
2120 {expr3} = "keep": keep the value of {expr1} 2124 {expr3} = "keep": keep the value of {expr1}
2121 {expr3} = "force": use the value of {expr2} 2125 {expr3} = "force": use the value of {expr2}
2122 {expr3} = "error": give an error message 2126 {expr3} = "error": give an error message *E737*
2123 When {expr3} is omitted then "force" is assumed. 2127 When {expr3} is omitted then "force" is assumed.
2124 2128
2125 {expr1} is changed when {expr2} is not empty. If necessary 2129 {expr1} is changed when {expr2} is not empty. If necessary
2126 make a copy of {expr1} first. 2130 make a copy of {expr1} first.
2127 {expr2} remains unchanged. 2131 {expr2} remains unchanged.
3073 < The current 'encoding' is used. Example for "utf-8": > 3077 < The current 'encoding' is used. Example for "utf-8": >
3074 nr2char(300) returns I with bow character 3078 nr2char(300) returns I with bow character
3075 < Note that a NUL character in the file is specified with 3079 < Note that a NUL character in the file is specified with
3076 nr2char(10), because NULs are represented with newline 3080 nr2char(10), because NULs are represented with newline
3077 characters. nr2char(0) is a real NUL and terminates the 3081 characters. nr2char(0) is a real NUL and terminates the
3078 string, thus isn't very useful. 3082 string, thus results in an empty string.
3079 3083
3080 prevnonblank({lnum}) *prevnonblank()* 3084 prevnonblank({lnum}) *prevnonblank()*
3081 Return the line number of the first line at or above {lnum} 3085 Return the line number of the first line at or above {lnum}
3082 that is not blank. Example: > 3086 that is not blank. Example: >
3083 let ind = indent(prevnonblank(v:lnum - 1)) 3087 let ind = indent(prevnonblank(v:lnum - 1))
3228 If you want a list to remain unmodified make a copy first: > 3232 If you want a list to remain unmodified make a copy first: >
3229 :let revlist = reverse(copy(mylist)) 3233 :let revlist = reverse(copy(mylist))
3230 3234
3231 search({pattern} [, {flags}]) *search()* 3235 search({pattern} [, {flags}]) *search()*
3232 Search for regexp pattern {pattern}. The search starts at the 3236 Search for regexp pattern {pattern}. The search starts at the
3233 cursor position. 3237 cursor position (you can use |cursor()| to set it).
3234 {flags} is a String, which can contain these character flags: 3238 {flags} is a String, which can contain these character flags:
3235 'b' search backward instead of forward 3239 'b' search backward instead of forward
3236 'n' do Not move the cursor 3240 'n' do Not move the cursor
3237 'w' wrap around the end of the file 3241 'w' wrap around the end of the file
3238 'W' don't wrap around the end of the file 3242 'W' don't wrap around the end of the file
4300 {idx1} can be omitted, zero is used instead. 4304 {idx1} can be omitted, zero is used instead.
4301 {idx2} can be omitted, meaning the end of the list. 4305 {idx2} can be omitted, meaning the end of the list.
4302 When the selected range of items is partly past the 4306 When the selected range of items is partly past the
4303 end of the list, items will be added. 4307 end of the list, items will be added.
4304 4308
4309 *:let+=* *:let-=* *:let.=*
4305 :let {var} += {expr1} Like ":let {var} = {var} + {expr1}". 4310 :let {var} += {expr1} Like ":let {var} = {var} + {expr1}".
4306 :let {var} -= {expr1} Like ":let {var} = {var} - {expr1}". 4311 :let {var} -= {expr1} Like ":let {var} = {var} - {expr1}".
4307 :let {var} .= {expr1} Like ":let {var} = {var} . {expr1}". 4312 :let {var} .= {expr1} Like ":let {var} = {var} . {expr1}".
4308 These fail if {var} was not set yet and when the type 4313 These fail if {var} was not set yet and when the type
4309 of {var} and {expr1} don't fit the operator. 4314 of {var} and {expr1} don't fit the operator.