Mercurial > vim
comparison runtime/doc/eval.txt @ 9737:35ce559b8553
commit https://github.com/vim/vim/commit/bc8801c9317eb721a2ee91322669f2dd5d136380
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Aug 2 21:04:33 2016 +0200
Updated runtime files.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 02 Aug 2016 21:15:06 +0200 |
parents | 80ac9cf77c9b |
children | 34cc6a101340 |
comparison
equal
deleted
inserted
replaced
9736:d963b7420aa2 | 9737:35ce559b8553 |
---|---|
1 *eval.txt* For Vim version 7.4. Last change: 2016 Jul 31 | 1 *eval.txt* For Vim version 7.4. Last change: 2016 Aug 02 |
2 | 2 |
3 | 3 |
4 VIM REFERENCE MANUAL by Bram Moolenaar | 4 VIM REFERENCE MANUAL by Bram Moolenaar |
5 | 5 |
6 | 6 |
260 To prepend or append an item turn the item into a list by putting [] around | 260 To prepend or append an item turn the item into a list by putting [] around |
261 it. To change a list in-place see |list-modification| below. | 261 it. To change a list in-place see |list-modification| below. |
262 | 262 |
263 | 263 |
264 Sublist ~ | 264 Sublist ~ |
265 | 265 *sublist* |
266 A part of the List can be obtained by specifying the first and last index, | 266 A part of the List can be obtained by specifying the first and last index, |
267 separated by a colon in square brackets: > | 267 separated by a colon in square brackets: > |
268 :let shortlist = mylist[2:-1] " get List [3, "four"] | 268 :let shortlist = mylist[2:-1] " get List [3, "four"] |
269 | 269 |
270 Omitting the first index is similar to zero. Omitting the last index is | 270 Omitting the first index is similar to zero. Omitting the last index is |
988 :let c = name[-1:] " last byte of a string | 988 :let c = name[-1:] " last byte of a string |
989 :let c = name[-2:-2] " last but one byte of a string | 989 :let c = name[-2:-2] " last but one byte of a string |
990 :let s = line(".")[4:] " from the fifth byte to the end | 990 :let s = line(".")[4:] " from the fifth byte to the end |
991 :let s = s[:-3] " remove last two bytes | 991 :let s = s[:-3] " remove last two bytes |
992 < | 992 < |
993 *sublist* *slice* | 993 *slice* |
994 If expr8 is a |List| this results in a new |List| with the items indicated by | 994 If expr8 is a |List| this results in a new |List| with the items indicated by |
995 the indexes expr1a and expr1b. This works like with a String, as explained | 995 the indexes expr1a and expr1b. This works like with a String, as explained |
996 just above, except that indexes out of range cause an error. Examples: > | 996 just above. Also see |sublist| below. Examples: > |
997 :let l = mylist[:3] " first four items | 997 :let l = mylist[:3] " first four items |
998 :let l = mylist[4:4] " List with one item | 998 :let l = mylist[4:4] " List with one item |
999 :let l = mylist[:] " shallow copy of a List | 999 :let l = mylist[:] " shallow copy of a List |
1000 | 1000 |
1001 Using expr8[expr1] or expr8[expr1a : expr1b] on a |Funcref| results in an | 1001 Using expr8[expr1] or expr8[expr1a : expr1b] on a |Funcref| results in an |
8290 : let x = 0 | 8290 : let x = 0 |
8291 : function! Bar() closure | 8291 : function! Bar() closure |
8292 : let x += 1 | 8292 : let x += 1 |
8293 : return x | 8293 : return x |
8294 : endfunction | 8294 : endfunction |
8295 : return function('Bar') | 8295 : return funcref('Bar') |
8296 :endfunction | 8296 :endfunction |
8297 | 8297 |
8298 :let F = Foo() | 8298 :let F = Foo() |
8299 :echo F() | 8299 :echo F() |
8300 < 1 > | 8300 < 1 > |