diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-02-08 08:07:51 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2024-02-08 08:08:18 +0800 |
commit | d75022d2059b660782ff2d68b2dd58916e603c95 (patch) | |
tree | 392d1e304425d35a2b07087a50ba7b3d8c4d5126 | |
parent | 70a00492962d3201603056d00fbf87c785106d0d (diff) | |
download | rneovim-d75022d2059b660782ff2d68b2dd58916e603c95.tar.gz rneovim-d75022d2059b660782ff2d68b2dd58916e603c95.tar.bz2 rneovim-d75022d2059b660782ff2d68b2dd58916e603c95.zip |
vim-patch:partial:9.1.0080: unexpected error for modifying final list using +=
Problem: unexpected error for modifying final list using += operator
(Ernie Rael)
Solution: Allow List value modification of a final variable using +=
operator
(Yegappan Lakshmanan)
fixes: vim/vim#13745
fixes: vim/vim#13959
closes: vim/vim#13962
https://github.com/vim/vim/commit/1af35631f85d2fcdc83c5d457af8273697f5146a
Only port eval.txt changes.
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
-rw-r--r-- | runtime/doc/eval.txt | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index 076d324b60..1e2b866190 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -374,6 +374,18 @@ To change part of a list you can specify the first and last item to be modified. The value must at least have the number of items in the range: > :let list[3:5] = [3, 4, 5] +To add items to a List in-place, you can use the |+=| operator: > + :let listA = [1, 2] + :let listA += [3, 4] +< +When two variables refer to the same List, changing one List in-place will +cause the referenced List to be changed in-place: > + :let listA = [1, 2] + :let listB = listA + :let listB += [3, 4] + :echo listA + [1, 2, 3, 4] +< Adding and removing items from a list is done with functions. Here are a few examples: > :call insert(list, 'a') " prepend item 'a' |