Mercurial > vim
comparison runtime/doc/eval.txt @ 258:f93df7322443
updated for version 7.0070
author | vimboss |
---|---|
date | Sat, 23 Apr 2005 20:52:00 +0000 |
parents | 4707450c2b33 |
children | a20218704019 |
comparison
equal
deleted
inserted
replaced
257:51a4d1c2a95b | 258:f93df7322443 |
---|---|
1 *eval.txt* For Vim version 7.0aa. Last change: 2005 Apr 04 | 1 *eval.txt* For Vim version 7.0aa. Last change: 2005 Apr 22 |
2 | 2 |
3 | 3 |
4 VIM REFERENCE MANUAL by Bram Moolenaar | 4 VIM REFERENCE MANUAL by Bram Moolenaar |
5 | 5 |
6 | 6 |
335 :call append('$', lines) " append text lines in buffer | 335 :call append('$', lines) " append text lines in buffer |
336 :let list = split("a b c") " create list from items in a string | 336 :let list = split("a b c") " create list from items in a string |
337 :let string = join(list, ', ') " create string from list items | 337 :let string = join(list, ', ') " create string from list items |
338 :let s = string(list) " String representation of list | 338 :let s = string(list) " String representation of list |
339 :call map(list, '">> " . v:val') " prepend ">> " to each item | 339 :call map(list, '">> " . v:val') " prepend ">> " to each item |
340 | |
341 Don't forget that a combination of features can make things simple. For | |
342 example, to add up all the numbers in a list: > | |
343 :exe 'let sum = ' . join(nrlist, '+') | |
340 | 344 |
341 | 345 |
342 1.4 Dictionaries ~ | 346 1.4 Dictionaries ~ |
343 *Dictionaries* *Dictionary* | 347 *Dictionaries* *Dictionary* |
344 A Dictionary is an associative array: Each entry has a key and a value. The | 348 A Dictionary is an associative array: Each entry has a key and a value. The |
3717 :let words = split(getline('.'), '\W\+') | 3721 :let words = split(getline('.'), '\W\+') |
3718 < Since empty strings are not added the "\+" isn't required but | 3722 < Since empty strings are not added the "\+" isn't required but |
3719 it makes the function work a bit faster. | 3723 it makes the function work a bit faster. |
3720 To split a string in individual characters: > | 3724 To split a string in individual characters: > |
3721 :for c in split(mystring, '\zs') | 3725 :for c in split(mystring, '\zs') |
3722 < The opposite function is |join()|. | 3726 < If you want to keep the separator you can also use '\zs': > |
3727 :echo split('abc:def:ghi', ':\zs') | |
3728 < ['abc:', 'def:', 'ghi'] ~ | |
3729 The opposite function is |join()|. | |
3723 | 3730 |
3724 | 3731 |
3725 strftime({format} [, {time}]) *strftime()* | 3732 strftime({format} [, {time}]) *strftime()* |
3726 The result is a String, which is a formatted date and time, as | 3733 The result is a String, which is a formatted date and time, as |
3727 specified by the {format} string. The given {time} is used, | 3734 specified by the {format} string. The given {time} is used, |