comparison runtime/doc/eval.txt @ 1668:0b796e045c42 v7.2b.000

updated for version 7.2b-000
author vimboss
date Sun, 13 Jul 2008 17:41:49 +0000
parents 5bbc2d6658ad
children f4f8014d516e
comparison
equal deleted inserted replaced
1667:131dbd3d2a4b 1668:0b796e045c42
1 *eval.txt* For Vim version 7.2a. Last change: 2008 Jun 24 1 *eval.txt* For Vim version 7.2b. Last change: 2008 Jul 09
2 2
3 3
4 VIM REFERENCE MANUAL by Bram Moolenaar 4 VIM REFERENCE MANUAL by Bram Moolenaar
5 5
6 6
2522 |user-functions|). 2522 |user-functions|).
2523 varname internal variable (see 2523 varname internal variable (see
2524 |internal-variables|). Also works 2524 |internal-variables|). Also works
2525 for |curly-braces-names|, |Dictionary| 2525 for |curly-braces-names|, |Dictionary|
2526 entries, |List| items, etc. Beware 2526 entries, |List| items, etc. Beware
2527 that this may cause functions to be 2527 that evaluating an index may cause an
2528 invoked cause an error message for an 2528 error message for an invalid
2529 invalid expression. 2529 expression. E.g.: >
2530 :let l = [1, 2, 3]
2531 :echo exists("l[5]")
2532 < 0 >
2533 :echo exists("l[xx]")
2534 < E121: Undefined variable: xx
2535 0
2530 :cmdname Ex command: built-in command, user 2536 :cmdname Ex command: built-in command, user
2531 command or command modifier |:command|. 2537 command or command modifier |:command|.
2532 Returns: 2538 Returns:
2533 1 for match with start of a command 2539 1 for match with start of a command
2534 2 full match with a command 2540 2 full match with a command
2943 2949
2944 getbufvar({expr}, {varname}) *getbufvar()* 2950 getbufvar({expr}, {varname}) *getbufvar()*
2945 The result is the value of option or local buffer variable 2951 The result is the value of option or local buffer variable
2946 {varname} in buffer {expr}. Note that the name without "b:" 2952 {varname} in buffer {expr}. Note that the name without "b:"
2947 must be used. 2953 must be used.
2954 When {varname} is empty returns a dictionary with all the
2955 buffer-local variables.
2948 This also works for a global or buffer-local option, but it 2956 This also works for a global or buffer-local option, but it
2949 doesn't work for a global variable, window-local variable or 2957 doesn't work for a global variable, window-local variable or
2950 window-local option. 2958 window-local option.
2951 For the use of {expr}, see |bufname()| above. 2959 For the use of {expr}, see |bufname()| above.
2952 When the buffer or variable doesn't exist an empty string is 2960 When the buffer or variable doesn't exist an empty string is
3294 3302
3295 The "**" item can be used to search in a directory tree. 3303 The "**" item can be used to search in a directory tree.
3296 For example, to find all "README.txt" files in the directories 3304 For example, to find all "README.txt" files in the directories
3297 in 'runtimepath' and below: > 3305 in 'runtimepath' and below: >
3298 :echo globpath(&rtp, "**/README.txt") 3306 :echo globpath(&rtp, "**/README.txt")
3299 < 3307 < Upwards search and limiting the depth of "**" is not
3308 supported, thus using 'path' will not always work properly.
3309
3300 *has()* 3310 *has()*
3301 has({feature}) The result is a Number, which is 1 if the feature {feature} is 3311 has({feature}) The result is a Number, which is 1 if the feature {feature} is
3302 supported, zero otherwise. The {feature} argument is a 3312 supported, zero otherwise. The {feature} argument is a
3303 string. See |feature-list| below. 3313 string. See |feature-list| below.
3304 Also see |exists()|. 3314 Also see |exists()|.
3359 3369
3360 histdel({history} [, {item}]) *histdel()* 3370 histdel({history} [, {item}]) *histdel()*
3361 Clear {history}, i.e. delete all its entries. See |hist-names| 3371 Clear {history}, i.e. delete all its entries. See |hist-names|
3362 for the possible values of {history}. 3372 for the possible values of {history}.
3363 3373
3364 If the parameter {item} is given as String, this is seen 3374 If the parameter {item} evaluates to a String, it is used as a
3365 as regular expression. All entries matching that expression 3375 regular expression. All entries matching that expression will
3366 will be removed from the history (if there are any). 3376 be removed from the history (if there are any).
3367 Upper/lowercase must match, unless "\c" is used |/\c|. 3377 Upper/lowercase must match, unless "\c" is used |/\c|.
3368 If {item} is a Number, it will be interpreted as index, see 3378 If {item} evaluates to a Number, it will be interpreted as
3369 |:history-indexing|. The respective entry will be removed 3379 an index, see |:history-indexing|. The respective entry will
3370 if it exists. 3380 be removed if it exists.
3371 3381
3372 The result is a Number: 1 for a successful operation, 3382 The result is a Number: 1 for a successful operation,
3373 otherwise 0 is returned. 3383 otherwise 0 is returned.
3374 3384
3375 Examples: 3385 Examples:
4276 4286
4277 *printf-%* 4287 *printf-%*
4278 % A '%' is written. No argument is converted. The 4288 % A '%' is written. No argument is converted. The
4279 complete conversion specification is "%%". 4289 complete conversion specification is "%%".
4280 4290
4281 Each argument can be Number or String and is converted 4291 When a Number argument is expected a String argument is also
4282 automatically to fit the conversion specifier. Any other 4292 accepted and automatically converted.
4283 argument type results in an error message. 4293 When a Float or String argument is expected a Number argument
4294 is also accepted and automatically converted.
4295 Any other argument type results in an error message.
4284 4296
4285 *E766* *E767* 4297 *E766* *E767*
4286 The number of {exprN} arguments must exactly match the number 4298 The number of {exprN} arguments must exactly match the number
4287 of "%" items. If there are not sufficient or too many 4299 of "%" items. If there are not sufficient or too many
4288 arguments an error is given. Up to 18 arguments can be used. 4300 arguments an error is given. Up to 18 arguments can be used.
4504 {list}. 4516 {list}.
4505 If you want a list to remain unmodified make a copy first: > 4517 If you want a list to remain unmodified make a copy first: >
4506 :let revlist = reverse(copy(mylist)) 4518 :let revlist = reverse(copy(mylist))
4507 4519
4508 round({expr}) *round()* 4520 round({expr}) *round()*
4509 Round off {expr} to a the nearest integral value and return it 4521 Round off {expr} to the nearest integral value and return it
4510 as a |Float|. If {expr} lies halfway between two integral 4522 as a |Float|. If {expr} lies halfway between two integral
4511 values, then use the larger one (away from zero). 4523 values, then use the larger one (away from zero).
4512 {expr} must evaluate to a |Float| or a |Number|. 4524 {expr} must evaluate to a |Float| or a |Number|.
4513 Examples: > 4525 Examples: >
4514 echo round(0.456) 4526 echo round(0.456)
5096 Examples: > 5108 Examples: >
5097 :echo sqrt(100) 5109 :echo sqrt(100)
5098 < 10.0 > 5110 < 10.0 >
5099 :echo sqrt(-4.01) 5111 :echo sqrt(-4.01)
5100 < nan 5112 < nan
5113 "nan" may be different, it depends on system libraries.
5101 {only available when compiled with the |+float| feature} 5114 {only available when compiled with the |+float| feature}
5102 5115
5103 5116
5104 str2float( {expr}) *str2float()* 5117 str2float( {expr}) *str2float()*
5105 Convert String {expr} to a Float. This mostly works the same 5118 Convert String {expr} to a Float. This mostly works the same
5482 < returns "Hello THere" > 5495 < returns "Hello THere" >
5483 echo tr("<blob>", "<>", "{}") 5496 echo tr("<blob>", "<>", "{}")
5484 < returns "{blob}" 5497 < returns "{blob}"
5485 5498
5486 trunc({expr}) *trunc()* 5499 trunc({expr}) *trunc()*
5487 Return the largest integral value with magnituted less than or 5500 Return the largest integral value with magnitude less than or
5488 equal to {expr} as a |Float| (truncate towards zero). 5501 equal to {expr} as a |Float| (truncate towards zero).
5489 {expr} must evaluate to a |Float| or a |Number|. 5502 {expr} must evaluate to a |Float| or a |Number|.
5490 Examples: > 5503 Examples: >
5491 echo trunc(1.456) 5504 echo trunc(1.456)
5492 < 1.0 > 5505 < 1.0 >
6392 :unlet list[3] " remove fourth item 6405 :unlet list[3] " remove fourth item
6393 :unlet list[3:] " remove fourth item to last 6406 :unlet list[3:] " remove fourth item to last
6394 < One item from a |Dictionary| can be removed at a time: > 6407 < One item from a |Dictionary| can be removed at a time: >
6395 :unlet dict['two'] 6408 :unlet dict['two']
6396 :unlet dict.two 6409 :unlet dict.two
6410 < This is especially useful to clean up used global
6411 variables and script-local variables (these are not
6412 deleted when the script ends). Function-local
6413 variables are automatically deleted when the function
6414 ends.
6397 6415
6398 :lockv[ar][!] [depth] {name} ... *:lockvar* *:lockv* 6416 :lockv[ar][!] [depth] {name} ... *:lockvar* *:lockv*
6399 Lock the internal variable {name}. Locking means that 6417 Lock the internal variable {name}. Locking means that
6400 it can no longer be changed (until it is unlocked). 6418 it can no longer be changed (until it is unlocked).
6401 A locked variable can be deleted: > 6419 A locked variable can be deleted: >