comparison runtime/doc/eval.txt @ 90:9d4f762cc1d9

updated for version 7.0036
author vimboss
date Sun, 09 Jan 2005 21:20:18 +0000
parents 014ba200db86
children a2081e6febb8
comparison
equal deleted inserted replaced
89:e1a8191c6768 90:9d4f762cc1d9
1 *eval.txt* For Vim version 7.0aa. Last change: 2005 Jan 08 1 *eval.txt* For Vim version 7.0aa. Last change: 2005 Jan 09
2 2
3 3
4 VIM REFERENCE MANUAL by Bram Moolenaar 4 VIM REFERENCE MANUAL by Bram Moolenaar
5 5
6 6
165 :let shortlist = mylist[2:-1] " get List [3, "four"] 165 :let shortlist = mylist[2:-1] " get List [3, "four"]
166 166
167 Omitting the first index is similar to zero. Omitting the last index is 167 Omitting the first index is similar to zero. Omitting the last index is
168 similar to -1. The difference is that there is no error if the items are not 168 similar to -1. The difference is that there is no error if the items are not
169 available. > 169 available. >
170 :let endlist = [2:] " from item 2 to the end: [3, "four"] 170 :let endlist = mylist[2:] " from item 2 to the end: [3, "four"]
171 :let shortlist = [2:2] " List with one item: [3] 171 :let shortlist = mylist[2:2] " List with one item: [3]
172 :let otherlist = [:] " make a copy of the List 172 :let otherlist = mylist[:] " make a copy of the List
173 173
174 174
175 List identity ~ 175 List identity ~
176 176
177 When variable "aa" is a list and you assign it to another variable "bb", both 177 When variable "aa" is a list and you assign it to another variable "bb", both
234 To change a specific item of a list use |:let| this way: > 234 To change a specific item of a list use |:let| this way: >
235 :let list[4] = "four" 235 :let list[4] = "four"
236 :let listlist[0][3] = item 236 :let listlist[0][3] = item
237 237
238 To change part of a list you can specify the first and last item to be 238 To change part of a list you can specify the first and last item to be
239 modified. The value must mach the range of replaced items: > 239 modified. The value must match the range of replaced items: >
240 :let list[3:5] = [3, 4, 5] 240 :let list[3:5] = [3, 4, 5]
241 241
242 Adding and removing items from a list is done with functions. Here are a few 242 Adding and removing items from a list is done with functions. Here are a few
243 examples: > 243 examples: >
244 :call insert(list, 'a') " prepend item 'a' 244 :call insert(list, 'a') " prepend item 'a'