Mercurial > vim
comparison runtime/doc/eval.txt @ 108:375b1d0f97b0
updated for version 7.0040
author | vimboss |
---|---|
date | Sun, 16 Jan 2005 22:02:49 +0000 |
parents | 0aa0e89bfd5f |
children | f6e567606d47 |
comparison
equal
deleted
inserted
replaced
107:9e65557da34c | 108:375b1d0f97b0 |
---|---|
1 *eval.txt* For Vim version 7.0aa. Last change: 2005 Jan 15 | 1 *eval.txt* For Vim version 7.0aa. Last change: 2005 Jan 16 |
2 | 2 |
3 | 3 |
4 VIM REFERENCE MANUAL by Bram Moolenaar | 4 VIM REFERENCE MANUAL by Bram Moolenaar |
5 | 5 |
6 | 6 |
258 :call insert(list, 'a', 3) " insert item 'a' before list[3] | 258 :call insert(list, 'a', 3) " insert item 'a' before list[3] |
259 :call add(list, "new") " append String item | 259 :call add(list, "new") " append String item |
260 :call add(list, [1, 2]) " append List as one new item | 260 :call add(list, [1, 2]) " append List as one new item |
261 :call extend(list, [1, 2]) " extend the list with two more items | 261 :call extend(list, [1, 2]) " extend the list with two more items |
262 :let i = remove(list, 3) " remove item 3 | 262 :let i = remove(list, 3) " remove item 3 |
263 :unlet list[3] " idem | |
263 :let l = remove(list, 3, -1) " remove items 3 to last item | 264 :let l = remove(list, 3, -1) " remove items 3 to last item |
265 :unlet list[3 : ] " idem | |
264 :call filter(list, 'v:val =~ "x"') " remove items with an 'x' | 266 :call filter(list, 'v:val =~ "x"') " remove items with an 'x' |
265 | 267 |
266 Changing the oder of items in a list: > | 268 Changing the oder of items in a list: > |
267 :call sort(list) " sort a list alphabetically | 269 :call sort(list) " sort a list alphabetically |
268 :call reverse(list) " reverse the order of items | 270 :call reverse(list) " reverse the order of items |
414 To change an already existing entry of a Dictionary, or to add a new entry, | 416 To change an already existing entry of a Dictionary, or to add a new entry, |
415 use |:let| this way: > | 417 use |:let| this way: > |
416 :let dict[4] = "four" | 418 :let dict[4] = "four" |
417 :let dict['one'] = item | 419 :let dict['one'] = item |
418 | 420 |
419 Removing an entry from a Dictionary is done with |remove()|: > | 421 Removing an entry from a Dictionary is done with |remove()| or |:unlet|. |
420 :let i = remove(dict, 'aaa') " remove item with key 'aaa' | 422 Three ways to remove the entry with key "aaa" from dict: > |
423 :let i = remove(dict, 'aaa') | |
424 :unlet dict.aaa | |
425 :unlet dict['aaa'] | |
421 | 426 |
422 Merging a Dictionary with another is done with |extend()|: > | 427 Merging a Dictionary with another is done with |extend()|: > |
423 :call extend(adict, bdict) " extend adict with entries from bdict | 428 :call extend(adict, bdict) " extend adict with entries from bdict |
424 | 429 |
425 Weeding out entries from a Dictionary can be done with |filter()|: > | 430 Weeding out entries from a Dictionary can be done with |filter()|: > |
4311 :unl[et][!] {var-name} ... | 4316 :unl[et][!] {var-name} ... |
4312 Remove the internal variable {var-name}. Several | 4317 Remove the internal variable {var-name}. Several |
4313 variable names can be given, they are all removed. | 4318 variable names can be given, they are all removed. |
4314 With [!] no error message is given for non-existing | 4319 With [!] no error message is given for non-existing |
4315 variables. | 4320 variables. |
4321 One or more items from a List can be removed: > | |
4322 :unlet list[3] " remove fourth item | |
4323 :unlet list[3:] " remove fourth item to last | |
4324 < One item from a Dictionary can be removed at a time: > | |
4325 :unlet dict['two'] | |
4326 :unlet dict.two | |
4316 | 4327 |
4317 :if {expr1} *:if* *:endif* *:en* *E171* *E579* *E580* | 4328 :if {expr1} *:if* *:endif* *:en* *E171* *E579* *E580* |
4318 :en[dif] Execute the commands until the next matching ":else" | 4329 :en[dif] Execute the commands until the next matching ":else" |
4319 or ":endif" if {expr1} evaluates to non-zero. | 4330 or ":endif" if {expr1} evaluates to non-zero. |
4320 | 4331 |