|
1 |
| -*eval.txt* For Vim version 9.1. Last change: 2024 Jan 14 |
| 1 | +*eval.txt* For Vim version 9.1. Last change: 2024 Feb 08 |
2 | 2 |
|
3 | 3 |
|
4 | 4 | VIM REFERENCE MANUAL by Bram Moolenaar
|
@@ -303,10 +303,15 @@ List concatenation ~
|
303 | 303 | *list-concatenation*
|
304 | 304 | Two lists can be concatenated with the "+" operator: >
|
305 | 305 | :let longlist = mylist + [5, 6]
|
306 |
| - :let mylist += [7, 8] |
| 306 | + :let longlist = [5, 6] + mylist |
| 307 | +To prepend or append an item, turn it into a list by putting [] around it. |
307 | 308 |
|
308 |
| -To prepend or append an item, turn the item into a list by putting [] around |
309 |
| -it. To change a list in-place, refer to |list-modification| below. |
| 309 | +A list can be concatenated with another one in-place using |:let+=| or |
| 310 | +|extend()|: > |
| 311 | + :let mylist += [7, 8] |
| 312 | + :call extend(mylist, [7, 8]) |
| 313 | +< |
| 314 | +See |list-modification| below for more about changing a list in-place. |
310 | 315 |
|
311 | 316 |
|
312 | 317 | Sublist ~
|
@@ -425,6 +430,18 @@ To change part of a list you can specify the first and last item to be
|
425 | 430 | modified. The value must at least have the number of items in the range: >
|
426 | 431 | :let list[3:5] = [3, 4, 5]
|
427 | 432 |
|
| 433 | +To add items to a List in-place, you can use |:let+=| (|list-concatenation|): > |
| 434 | + :let listA = [1, 2] |
| 435 | + :let listA += [3, 4] |
| 436 | +< |
| 437 | +When two variables refer to the same List, changing one List in-place will |
| 438 | +cause the referenced List to be changed in-place: > |
| 439 | + :let listA = [1, 2] |
| 440 | + :let listB = listA |
| 441 | + :let listB += [3, 4] |
| 442 | + :echo listA |
| 443 | + [1, 2, 3, 4] |
| 444 | +< |
428 | 445 | Adding and removing items from a list is done with functions. Here are a few
|
429 | 446 | examples: >
|
430 | 447 | :call insert(list, 'a') " prepend item 'a'
|
@@ -745,12 +762,15 @@ This calls Doit() with 0x11, 0x22 and 0x33.
|
745 | 762 |
|
746 | 763 |
|
747 | 764 | Blob concatenation ~
|
748 |
| - |
| 765 | + *blob-concatenation* |
749 | 766 | Two blobs can be concatenated with the "+" operator: >
|
750 | 767 | :let longblob = myblob + 0z4455
|
| 768 | + :let longblob = 0z4455 + myblob |
| 769 | +< |
| 770 | +A blob can be concatenated with another one in-place using |:let+=|: > |
751 | 771 | :let myblob += 0z6677
|
752 |
| -
|
753 |
| -To change a blob in-place see |blob-modification| below. |
| 772 | +< |
| 773 | +See |blob-modification| below for more about changing a blob in-place. |
754 | 774 |
|
755 | 775 |
|
756 | 776 | Part of a blob ~
|
@@ -793,6 +813,18 @@ To change part of a blob you can specify the first and last byte to be
|
793 | 813 | modified. The value must have the same number of bytes in the range: >
|
794 | 814 | :let blob[3:5] = 0z334455
|
795 | 815 |
|
| 816 | +To add items to a Blob in-place, you can use |:let+=| (|blob-concatenation|): > |
| 817 | + :let blobA = 0z1122 |
| 818 | + :let blobA += 0z3344 |
| 819 | +< |
| 820 | +When two variables refer to the same Blob, changing one Blob in-place will |
| 821 | +cause the referenced Blob to be changed in-place: > |
| 822 | + :let blobA = 0z1122 |
| 823 | + :let blobB = blobA |
| 824 | + :let blobB += 0z3344 |
| 825 | + :echo blobA |
| 826 | + 0z11223344 |
| 827 | +< |
796 | 828 | You can also use the functions |add()|, |remove()| and |insert()|.
|
797 | 829 |
|
798 | 830 |
|
@@ -2005,9 +2037,14 @@ v:collate The current locale setting for collation order of the runtime
|
2005 | 2037 | *v:colornames*
|
2006 | 2038 | v:colornames A dictionary that maps color names to hex color strings. These
|
2007 | 2039 | color names can be used with the |highlight-guifg|,
|
2008 |
| - |highlight-guibg|, and |highlight-guisp| parameters. Updating |
2009 |
| - an entry in v:colornames has no immediate effect on the syntax |
2010 |
| - highlighting. The highlight commands (probably in a |
| 2040 | + |highlight-guibg|, and |highlight-guisp| parameters. |
| 2041 | + |
| 2042 | + The key values in the dictionary (the color names) should be |
| 2043 | + lower cased, because Vim looks up a color by its lower case |
| 2044 | + name. |
| 2045 | + |
| 2046 | + Updating an entry in v:colornames has no immediate effect on |
| 2047 | + the syntax highlighting. The highlight commands (probably in a |
2011 | 2048 | colorscheme script) need to be re-evaluated in order to use
|
2012 | 2049 | the updated color values. For example: >
|
2013 | 2050 |
|
@@ -2804,6 +2841,8 @@ declarations and assignments do not use a command. |vim9-declaration|
|
2804 | 2841 | :let {var} ..= {expr1} Like ":let {var} = {var} .. {expr1}".
|
2805 | 2842 | These fail if {var} was not set yet and when the type
|
2806 | 2843 | of {var} and {expr1} don't fit the operator.
|
| 2844 | + `+=` modifies a |List| or a |Blob| in-place instead of |
| 2845 | + creating a new one. |
2807 | 2846 | `.=` is not supported with Vim script version 2 and
|
2808 | 2847 | later, see |vimscript-version|.
|
2809 | 2848 |
|
|
0 commit comments