Mercurial > vim
comparison runtime/doc/eval.txt @ 133:bcb347a8f934
updated for version 7.0044
author | vimboss |
---|---|
date | Tue, 25 Jan 2005 22:12:55 +0000 |
parents | f67f8a8d81ba |
children | 8ecb0db93e9a |
comparison
equal
deleted
inserted
replaced
132:d6009de12681 | 133:bcb347a8f934 |
---|---|
1 *eval.txt* For Vim version 7.0aa. Last change: 2005 Jan 20 | 1 *eval.txt* For Vim version 7.0aa. Last change: 2005 Jan 25 |
2 | 2 |
3 | 3 |
4 VIM REFERENCE MANUAL by Bram Moolenaar | 4 VIM REFERENCE MANUAL by Bram Moolenaar |
5 | 5 |
6 | 6 |
990 |local-variable| l: Local to a function. | 990 |local-variable| l: Local to a function. |
991 |script-variable| s: Local to a |:source|'ed Vim script. | 991 |script-variable| s: Local to a |:source|'ed Vim script. |
992 |function-argument| a: Function argument (only inside a function). | 992 |function-argument| a: Function argument (only inside a function). |
993 |vim-variable| v: Global, predefined by Vim. | 993 |vim-variable| v: Global, predefined by Vim. |
994 | 994 |
995 The scope name by itself can be used as a Dictionary. For example, to delete | |
996 all script-local variables: > | |
997 :for k in keys(s:) | |
998 : unlet s:[k] | |
999 :endfor | |
1000 < | |
995 *buffer-variable* *b:var* | 1001 *buffer-variable* *b:var* |
996 A variable name that is preceded with "b:" is local to the current buffer. | 1002 A variable name that is preceded with "b:" is local to the current buffer. |
997 Thus you can have several "b:foo" variables, one for each buffer. | 1003 Thus you can have several "b:foo" variables, one for each buffer. |
998 This kind of variable is deleted when the buffer is wiped out or deleted with | 1004 This kind of variable is deleted when the buffer is wiped out or deleted with |
999 |:bdelete|. | 1005 |:bdelete|. |
1505 setwinvar( {nr}, {varname}, {val}) set {varname} in window {nr} to {val} | 1511 setwinvar( {nr}, {varname}, {val}) set {varname} in window {nr} to {val} |
1506 simplify( {filename}) String simplify filename as much as possible | 1512 simplify( {filename}) String simplify filename as much as possible |
1507 sort( {list} [, {func}]) List sort {list}, using {func} to compare | 1513 sort( {list} [, {func}]) List sort {list}, using {func} to compare |
1508 split( {expr} [, {pat}]) List make List from {pat} separated {expr} | 1514 split( {expr} [, {pat}]) List make List from {pat} separated {expr} |
1509 strftime( {format}[, {time}]) String time in specified format | 1515 strftime( {format}[, {time}]) String time in specified format |
1510 stridx( {haystack}, {needle}) Number first index of {needle} in {haystack} | 1516 stridx( {haystack}, {needle}[, {start}]) |
1517 Number index of {needle} in {haystack} | |
1511 string( {expr}) String String representation of {expr} value | 1518 string( {expr}) String String representation of {expr} value |
1512 strlen( {expr}) Number length of the String {expr} | 1519 strlen( {expr}) Number length of the String {expr} |
1513 strpart( {src}, {start}[, {len}]) | 1520 strpart( {src}, {start}[, {len}]) |
1514 String {len} characters of {src} at {start} | 1521 String {len} characters of {src} at {start} |
1515 strridx( {haystack}, {needle}) Number last index of {needle} in {haystack} | 1522 strridx( {haystack}, {needle}) Number last index of {needle} in {haystack} |
3505 :echo strftime("%c", getftime("file.c")) | 3512 :echo strftime("%c", getftime("file.c")) |
3506 Show mod time of file.c. | 3513 Show mod time of file.c. |
3507 < Not available on all systems. To check use: > | 3514 < Not available on all systems. To check use: > |
3508 :if exists("*strftime") | 3515 :if exists("*strftime") |
3509 | 3516 |
3510 stridx({haystack}, {needle}) *stridx()* | 3517 stridx({haystack}, {needle} [, {start}]) *stridx()* |
3511 The result is a Number, which gives the index in {haystack} of | 3518 The result is a Number, which gives the byte index in |
3512 the first occurrence of the String {needle} in the String | 3519 {haystack} of the first occurrence of the String {needle}. |
3513 {haystack}. The search is done case-sensitive. For advanced | 3520 If {start} is specified, the String {needle} is searched from |
3514 searches use |match()|. | 3521 the byte index {start} in the String {haystack}. |
3515 If the {needle} does not occur in {haystack} it returns -1. | 3522 The search is done case-sensitive. |
3523 For pattern searches use |match()|. | |
3524 -1 is returned if the {needle} does not occur in {haystack}. | |
3516 See also |strridx()|. Examples: > | 3525 See also |strridx()|. Examples: > |
3517 :echo stridx("An Example", "Example") 3 | 3526 :echo stridx("An Example", "Example") 3 |
3518 :echo stridx("Starting point", "Start") 0 | 3527 :echo stridx("Starting point", "Start") 0 |
3519 :echo stridx("Starting point", "start") -1 | 3528 :echo stridx("Starting point", "start") -1 |
3520 < | 3529 < |
3556 example, to get three bytes under and after the cursor: > | 3565 example, to get three bytes under and after the cursor: > |
3557 strpart(getline(line(".")), col(".") - 1, 3) | 3566 strpart(getline(line(".")), col(".") - 1, 3) |
3558 < | 3567 < |
3559 strridx({haystack}, {needle}) *strridx()* | 3568 strridx({haystack}, {needle}) *strridx()* |
3560 The result is a Number, which gives the index in {haystack} of | 3569 The result is a Number, which gives the index in {haystack} of |
3561 the last occurrence of the String {needle} in the String | 3570 the last occurrence of the String {needle}. |
3562 {haystack}. The search is done case-sensitive. For advanced | 3571 The search is done case-sensitive. |
3563 searches use |match()|. | 3572 For pattern searches use |match()|. |
3564 If the {needle} does not occur in {haystack} it returns -1. | 3573 -1 is returned if the {needle} does not occur in {haystack}. |
3565 If the {needle} is empty the length of {haystack} is returned. | 3574 If the {needle} is empty the length of {haystack} is returned. |
3566 See also |stridx()|. Examples: > | 3575 See also |stridx()|. Examples: > |
3567 :echo strridx("an angry armadillo", "an") 3 | 3576 :echo strridx("an angry armadillo", "an") 3 |
3568 < | 3577 < |
3569 strtrans({expr}) *strtrans()* | 3578 strtrans({expr}) *strtrans()* |
4067 "init" is added if it didn't exist yet. Otherwise [!] | 4076 "init" is added if it didn't exist yet. Otherwise [!] |
4068 is required to overwrite an existing function. The | 4077 is required to overwrite an existing function. The |
4069 result is a |Funcref| to a numbered function. The | 4078 result is a |Funcref| to a numbered function. The |
4070 function can only be used with a |Funcref| and will be | 4079 function can only be used with a |Funcref| and will be |
4071 deleted if there are no more references to it. | 4080 deleted if there are no more references to it. |
4072 *function-argument* *a:var* | |
4073 An argument can be defined by giving its name. In the | |
4074 function this can then be used as "a:name" ("a:" for | |
4075 argument). | |
4076 Up to 20 arguments can be given, separated by commas. | |
4077 Finally, an argument "..." can be specified, which | |
4078 means that more arguments may be following. In the | |
4079 function they can be used as "a:1", "a:2", etc. "a:0" | |
4080 is set to the number of extra arguments (which can be | |
4081 0). | |
4082 When not using "...", the number of arguments in a | |
4083 function call must be equal to the number of named | |
4084 arguments. When using "...", the number of arguments | |
4085 may be larger. | |
4086 It is also possible to define a function without any | |
4087 arguments. You must still supply the () then. | |
4088 The body of the function follows in the next lines, | |
4089 until the matching |:endfunction|. It is allowed to | |
4090 define another function inside a function body. | |
4091 *E127* *E122* | 4081 *E127* *E122* |
4092 When a function by this name already exists and [!] is | 4082 When a function by this name already exists and [!] is |
4093 not used an error message is given. When [!] is used, | 4083 not used an error message is given. When [!] is used, |
4094 an existing function is silently replaced. Unless it | 4084 an existing function is silently replaced. Unless it |
4095 is currently being executed, that is an error. | 4085 is currently being executed, that is an error. |
4086 | |
4087 For the {arguments} see |function-argument|. | |
4088 | |
4096 *a:firstline* *a:lastline* | 4089 *a:firstline* *a:lastline* |
4097 When the [range] argument is added, the function is | 4090 When the [range] argument is added, the function is |
4098 expected to take care of a range itself. The range is | 4091 expected to take care of a range itself. The range is |
4099 passed as "a:firstline" and "a:lastline". If [range] | 4092 passed as "a:firstline" and "a:lastline". If [range] |
4100 is excluded, ":{range}call" will call the function for | 4093 is excluded, ":{range}call" will call the function for |
4137 following the ":finally" up to the matching |:endtry| | 4130 following the ":finally" up to the matching |:endtry| |
4138 are executed first. This process applies to all | 4131 are executed first. This process applies to all |
4139 nested ":try"s inside the function. The function | 4132 nested ":try"s inside the function. The function |
4140 returns at the outermost ":endtry". | 4133 returns at the outermost ":endtry". |
4141 | 4134 |
4142 | 4135 *function-argument* *a:var* |
4136 An argument can be defined by giving its name. In the function this can then | |
4137 be used as "a:name" ("a:" for argument). | |
4138 *a:0* *a:1* *a:000* *E740* | |
4139 Up to 20 arguments can be given, separated by commas. After the named | |
4140 arguments an argument "..." can be specified, which means that more arguments | |
4141 may optionally be following. In the function the extra arguments can be used | |
4142 as "a:1", "a:2", etc. "a:0" is set to the number of extra arguments (which | |
4143 can be 0). "a:000" is set to a List that contains these arguments. | |
4144 | |
4145 When not using "...", the number of arguments in a function call must be equal | |
4146 to the number of named arguments. When using "...", the number of arguments | |
4147 may be larger. | |
4148 | |
4149 It is also possible to define a function without any arguments. You must | |
4150 still supply the () then. The body of the function follows in the next lines, | |
4151 until the matching |:endfunction|. It is allowed to define another function | |
4152 inside a function body. | |
4153 | |
4154 *local-variables* | |
4143 Inside a function variables can be used. These are local variables, which | 4155 Inside a function variables can be used. These are local variables, which |
4144 will disappear when the function returns. Global variables need to be | 4156 will disappear when the function returns. Global variables need to be |
4145 accessed with "g:". | 4157 accessed with "g:". |
4146 | 4158 |
4147 Example: > | 4159 Example: > |