comparison runtime/doc/eval.txt @ 140:8ecb0db93e9a

updated for version 7.0045
author vimboss
date Thu, 27 Jan 2005 14:41:15 +0000
parents bcb347a8f934
children 72aefd4c1e0d
comparison
equal deleted inserted replaced
139:a217baa06d43 140:8ecb0db93e9a
1 *eval.txt* For Vim version 7.0aa. Last change: 2005 Jan 25 1 *eval.txt* For Vim version 7.0aa. Last change: 2005 Jan 27
2 2
3 3
4 VIM REFERENCE MANUAL by Bram Moolenaar 4 VIM REFERENCE MANUAL by Bram Moolenaar
5 5
6 6
1456 inputrestore() Number restore typeahead 1456 inputrestore() Number restore typeahead
1457 inputsave() Number save and clear typeahead 1457 inputsave() Number save and clear typeahead
1458 inputsecret( {prompt} [, {text}]) String like input() but hiding the text 1458 inputsecret( {prompt} [, {text}]) String like input() but hiding the text
1459 insert( {list}, {item} [, {idx}]) List insert {item} in {list} [before {idx}] 1459 insert( {list}, {item} [, {idx}]) List insert {item} in {list} [before {idx}]
1460 isdirectory( {directory}) Number TRUE if {directory} is a directory 1460 isdirectory( {directory}) Number TRUE if {directory} is a directory
1461 items( {dict}) List List of key-value pairs in {dict}
1461 join( {list} [, {sep}]) String join {list} items into one String 1462 join( {list} [, {sep}]) String join {list} items into one String
1462 keys( {dict}) List List of keys in {dict} 1463 keys( {dict}) List List of keys in {dict}
1463 len( {expr}) Number the length of {expr} 1464 len( {expr}) Number the length of {expr}
1464 libcall( {lib}, {func}, {arg}) String call {func} in library {lib} with {arg} 1465 libcall( {lib}, {func}, {arg}) String call {func} in library {lib} with {arg}
1465 libcallnr( {lib}, {func}, {arg}) Number idem, but return a Number 1466 libcallnr( {lib}, {func}, {arg}) Number idem, but return a Number
1517 Number index of {needle} in {haystack} 1518 Number index of {needle} in {haystack}
1518 string( {expr}) String String representation of {expr} value 1519 string( {expr}) String String representation of {expr} value
1519 strlen( {expr}) Number length of the String {expr} 1520 strlen( {expr}) Number length of the String {expr}
1520 strpart( {src}, {start}[, {len}]) 1521 strpart( {src}, {start}[, {len}])
1521 String {len} characters of {src} at {start} 1522 String {len} characters of {src} at {start}
1522 strridx( {haystack}, {needle}) Number last index of {needle} in {haystack} 1523 strridx( {haystack}, {needle} [, {start}])
1524 Number last index of {needle} in {haystack}
1523 strtrans( {expr}) String translate string to make it printable 1525 strtrans( {expr}) String translate string to make it printable
1524 submatch( {nr}) String specific match in ":substitute" 1526 submatch( {nr}) String specific match in ":substitute"
1525 substitute( {expr}, {pat}, {sub}, {flags}) 1527 substitute( {expr}, {pat}, {sub}, {flags})
1526 String all {pat} in {expr} replaced with {sub} 1528 String all {pat} in {expr} replaced with {sub}
1527 synID( {lnum}, {col}, {trans}) Number syntax ID at {lnum} and {col} 1529 synID( {lnum}, {col}, {trans}) Number syntax ID at {lnum} and {col}
1533 tolower( {expr}) String the String {expr} switched to lowercase 1535 tolower( {expr}) String the String {expr} switched to lowercase
1534 toupper( {expr}) String the String {expr} switched to uppercase 1536 toupper( {expr}) String the String {expr} switched to uppercase
1535 tr( {src}, {fromstr}, {tostr}) String translate chars of {src} in {fromstr} 1537 tr( {src}, {fromstr}, {tostr}) String translate chars of {src} in {fromstr}
1536 to chars in {tostr} 1538 to chars in {tostr}
1537 type( {name}) Number type of variable {name} 1539 type( {name}) Number type of variable {name}
1540 values( {dict}) List List of values in {dict}
1538 virtcol( {expr}) Number screen column of cursor or mark 1541 virtcol( {expr}) Number screen column of cursor or mark
1539 visualmode( [expr]) String last visual mode used 1542 visualmode( [expr]) String last visual mode used
1540 winbufnr( {nr}) Number buffer number of window {nr} 1543 winbufnr( {nr}) Number buffer number of window {nr}
1541 wincol() Number window column of the cursor 1544 wincol() Number window column of the cursor
1542 winheight( {nr}) Number height of window {nr} 1545 winheight( {nr}) Number height of window {nr}
2264 function({name}) *function()* *E700* 2267 function({name}) *function()* *E700*
2265 Return a Funcref variable that refers to function {name}. 2268 Return a Funcref variable that refers to function {name}.
2266 {name} can be a user defined function or an internal function. 2269 {name} can be a user defined function or an internal function.
2267 2270
2268 2271
2269 get({list}, {idx} [, {default}]) *get* 2272 get({list}, {idx} [, {default}]) *get()*
2270 Get item {idx} from List {list}. When this item is not 2273 Get item {idx} from List {list}. When this item is not
2271 available return {default}. Return zero when {default} is 2274 available return {default}. Return zero when {default} is
2272 omitted. 2275 omitted.
2273 get({dict}, {key} [, {default}]) 2276 get({dict}, {key} [, {default}])
2274 Get item with key {key} from Dictionary {dict}. When this 2277 Get item with key {key} from Dictionary {dict}. When this
2778 The result is a Number, which is non-zero when a directory 2781 The result is a Number, which is non-zero when a directory
2779 with the name {directory} exists. If {directory} doesn't 2782 with the name {directory} exists. If {directory} doesn't
2780 exist, or isn't a directory, the result is FALSE. {directory} 2783 exist, or isn't a directory, the result is FALSE. {directory}
2781 is any expression, which is used as a String. 2784 is any expression, which is used as a String.
2782 2785
2786 items({dict}) *items()*
2787 Return a List with all the key-value pairs of {dict}. Each
2788 List item is a list with two items: the key of a {dict} entry
2789 and the value of this entry. The List is in arbitrary order.
2790
2783 2791
2784 join({list} [, {sep}]) *join()* 2792 join({list} [, {sep}]) *join()*
2785 Join the items in {list} together into one String. 2793 Join the items in {list} together into one String.
2786 When {sep} is specified it is put in between the items. If 2794 When {sep} is specified it is put in between the items. If
2787 {sep} is omitted a single space is used. 2795 {sep} is omitted a single space is used.
3515 :if exists("*strftime") 3523 :if exists("*strftime")
3516 3524
3517 stridx({haystack}, {needle} [, {start}]) *stridx()* 3525 stridx({haystack}, {needle} [, {start}]) *stridx()*
3518 The result is a Number, which gives the byte index in 3526 The result is a Number, which gives the byte index in
3519 {haystack} of the first occurrence of the String {needle}. 3527 {haystack} of the first occurrence of the String {needle}.
3520 If {start} is specified, the String {needle} is searched from 3528 If {start} is specified, the search starts at index {start}.
3521 the byte index {start} in the String {haystack}. 3529 This can be used to find a second match: >
3522 The search is done case-sensitive. 3530 :let comma1 = stridx(line, ",")
3531 :let comma2 = stridx(line, ",", comma1 + 1)
3532 < The search is done case-sensitive.
3523 For pattern searches use |match()|. 3533 For pattern searches use |match()|.
3524 -1 is returned if the {needle} does not occur in {haystack}. 3534 -1 is returned if the {needle} does not occur in {haystack}.
3525 See also |strridx()|. Examples: > 3535 See also |strridx()|.
3536 Examples: >
3526 :echo stridx("An Example", "Example") 3 3537 :echo stridx("An Example", "Example") 3
3527 :echo stridx("Starting point", "Start") 0 3538 :echo stridx("Starting point", "Start") 0
3528 :echo stridx("Starting point", "start") -1 3539 :echo stridx("Starting point", "start") -1
3529 < 3540 <
3530 *string()* 3541 *string()*
3563 strpart("abcdefg", 3) == "defg" 3574 strpart("abcdefg", 3) == "defg"
3564 < Note: To get the first character, {start} must be 0. For 3575 < Note: To get the first character, {start} must be 0. For
3565 example, to get three bytes under and after the cursor: > 3576 example, to get three bytes under and after the cursor: >
3566 strpart(getline(line(".")), col(".") - 1, 3) 3577 strpart(getline(line(".")), col(".") - 1, 3)
3567 < 3578 <
3568 strridx({haystack}, {needle}) *strridx()* 3579 strridx({haystack}, {needle} [, {start}]) *strridx()*
3569 The result is a Number, which gives the index in {haystack} of 3580 The result is a Number, which gives the byte index in
3570 the last occurrence of the String {needle}. 3581 {haystack} of the last occurrence of the String {needle}.
3571 The search is done case-sensitive. 3582 When {start} is specified, matches beyond this index are
3583 ignored. This can be used to find a match before a previous
3584 match: >
3585 :let lastcomma = strridx(line, ",")
3586 :let comma2 = strridx(line, ",", lastcomma - 1)
3587 < The search is done case-sensitive.
3572 For pattern searches use |match()|. 3588 For pattern searches use |match()|.
3573 -1 is returned if the {needle} does not occur in {haystack}. 3589 -1 is returned if the {needle} does not occur in {haystack}.
3574 If the {needle} is empty the length of {haystack} is returned. 3590 If the {needle} is empty the length of {haystack} is returned.
3575 See also |stridx()|. Examples: > 3591 See also |stridx()|. Examples: >
3576 :echo strridx("an angry armadillo", "an") 3 3592 :echo strridx("an angry armadillo", "an") 3
3739 To avoid the magic numbers it can be used this way: > 3755 To avoid the magic numbers it can be used this way: >
3740 :if type(myvar) == type(0) 3756 :if type(myvar) == type(0)
3741 :if type(myvar) == type("") 3757 :if type(myvar) == type("")
3742 :if type(myvar) == type(function("tr")) 3758 :if type(myvar) == type(function("tr"))
3743 :if type(myvar) == type([]) 3759 :if type(myvar) == type([])
3760
3761 values({dict}) *values()*
3762 Return a List with all the values of {dict}. The List is in
3763 arbitrary order.
3764
3744 3765
3745 virtcol({expr}) *virtcol()* 3766 virtcol({expr}) *virtcol()*
3746 The result is a Number, which is the screen column of the file 3767 The result is a Number, which is the screen column of the file
3747 position given with {expr}. That is, the last screen position 3768 position given with {expr}. That is, the last screen position
3748 occupied by the character at that position, when the screen 3769 occupied by the character at that position, when the screen
4159 Example: > 4180 Example: >
4160 :function Table(title, ...) 4181 :function Table(title, ...)
4161 : echohl Title 4182 : echohl Title
4162 : echo a:title 4183 : echo a:title
4163 : echohl None 4184 : echohl None
4164 : let idx = 1 4185 : echo a:0 . " items:"
4165 : while idx <= a:0 4186 : for s in a:000
4166 : echo a:{idx} . ' ' 4187 : echon ' ' . s
4167 : let idx = idx + 1 4188 : endfor
4168 : endwhile
4169 : return idx
4170 :endfunction 4189 :endfunction
4171 4190
4172 This function can then be called with: > 4191 This function can then be called with: >
4173 let lines = Table("Table", "line1", "line2") 4192 call Table("Table", "line1", "line2")
4174 let lines = Table("Empty Table") 4193 call Table("Empty Table")
4175 4194
4176 To return more than one value, pass the name of a global variable: > 4195 To return more than one value, pass the name of a global variable: >
4177 :function Compute(n1, n2, divname) 4196 :function Compute(n1, n2, divname)
4178 : if a:n2 == 0 4197 : if a:n2 == 0
4179 : return "fail" 4198 : return "fail"
4409 :let [{name1}, {name2}, ...] -= {expr1} 4428 :let [{name1}, {name2}, ...] -= {expr1}
4410 Like above, but append/add/subtract the value for each 4429 Like above, but append/add/subtract the value for each
4411 List item. 4430 List item.
4412 4431
4413 :let [{name}, ..., ; {lastname}] = {expr1} 4432 :let [{name}, ..., ; {lastname}] = {expr1}
4414 Like |let-unpack| above, but the List may have more 4433 Like |:let-unpack| above, but the List may have more
4415 items than there are names. A list of the remaining 4434 items than there are names. A list of the remaining
4416 items is assigned to {lastname}. If there are no 4435 items is assigned to {lastname}. If there are no
4417 remaining items {lastname} is set to an empty list. 4436 remaining items {lastname} is set to an empty list.
4418 Example: > 4437 Example: >
4419 :let [a, b; rest] = ["aval", "bval", 3, 4] 4438 :let [a, b; rest] = ["aval", "bval", 3, 4]