summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2014-03-25 18:24:23 +0100
committerBram Moolenaar <Bram@vim.org>2014-03-25 18:24:23 +0100
commit327aa02ddaafa7c4585120ed152e078b9d74acea (patch)
treef3e621ae32a7ffe67dfa863049a0d50467cbd21b /runtime
parent1a3eb8e1b51015b99d2e68242dc5326153edc72f (diff)
updated for version 7.4.218v7.4.218
Problem: It's not easy to remove duplicates from a list. Solution: Add the uniq() function. (LCD)
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/change.txt2
-rw-r--r--runtime/doc/eval.txt25
-rw-r--r--runtime/doc/version7.txt1
3 files changed, 23 insertions, 5 deletions
diff --git a/runtime/doc/change.txt b/runtime/doc/change.txt
index d6daf50d44..da981c4836 100644
--- a/runtime/doc/change.txt
+++ b/runtime/doc/change.txt
@@ -1650,7 +1650,7 @@ And a few warnings:
7. Sorting text *sorting*
Vim has a sorting function and a sorting command. The sorting function can be
-found here: |sort()|.
+found here: |sort()|, |uniq()|.
*:sor* *:sort*
:[range]sor[t][!] [i][u][r][n][x][o] [/{pattern}/]
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 661832d124..56585d1bad 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -327,6 +327,7 @@ examples: >
Changing the order of items in a list: >
:call sort(list) " sort a list alphabetically
:call reverse(list) " reverse the order of items
+ :call uniq(sort(list)) " sort and remove duplicates
For loop ~
@@ -2005,6 +2006,8 @@ trunc( {expr}) Float truncate Float {expr}
type( {name}) Number type of variable {name}
undofile( {name}) String undo file name for {name}
undotree() List undo file tree
+uniq( {list} [, {func} [, {dict}]])
+ List remove adjacent duplicates from a list
values( {dict}) List values in {dict}
virtcol( {expr}) Number screen column of cursor or mark
visualmode( [expr]) String last visual mode used
@@ -5488,20 +5491,26 @@ sinh({expr}) *sinh()*
sort({list} [, {func} [, {dict}]]) *sort()* *E702*
- Sort the items in {list} in-place. Returns {list}. If you
- want a list to remain unmodified make a copy first: >
+ Sort the items in {list} in-place. Returns {list}.
+
+ If you want a list to remain unmodified make a copy first: >
:let sortedlist = sort(copy(mylist))
< Uses the string representation of each item to sort on.
Numbers sort after Strings, |Lists| after Numbers.
For sorting text in the current buffer use |:sort|.
+
When {func} is given and it is one then case is ignored.
- {dict} is for functions with the "dict" attribute. It will be
- used to set the local variable "self". |Dictionary-function|
When {func} is a |Funcref| or a function name, this function
is called to compare items. The function is invoked with two
items as argument and must return zero if they are equal, 1 or
bigger if the first one sorts after the second one, -1 or
smaller if the first one sorts before the second one.
+
+ {dict} is for functions with the "dict" attribute. It will be
+ used to set the local variable "self". |Dictionary-function|
+
+ Also see |uniq()|.
+
Example: >
func MyCompare(i1, i2)
return a:i1 == a:i2 ? 0 : a:i1 > a:i2 ? 1 : -1
@@ -6169,6 +6178,14 @@ undotree() *undotree()*
blocks. Each item may again have an "alt"
item.
+uniq({list} [, {func} [, {dict}]]) *uniq()* *E882*
+ Remove second and succeeding copies of repeated adjacent
+ {list} items in-place. Returns {list}. If you want a list
+ to remain unmodified make a copy first: >
+ :let newlist = uniq(copy(mylist))
+< The default compare function uses the string representation of
+ each item. For the use of {func} and {dict} see |sort()|.
+
values({dict}) *values()*
Return a |List| with all the values of {dict}. The |List| is
in arbitrary order.
diff --git a/runtime/doc/version7.txt b/runtime/doc/version7.txt
index ab4e385e89..1bff5b5da9 100644
--- a/runtime/doc/version7.txt
+++ b/runtime/doc/version7.txt
@@ -942,6 +942,7 @@ New and extended functions: ~
|tagfiles()| List with tags file names
|taglist()| get list of matching tags (Yegappan Lakshmanan)
|tr()| translate characters (Ron Aaron)
+|uniq()| remove copies of repeated adjacent list items
|values()| get List of Dictionary values
|winnr()| takes an argument: what window to use
|winrestview()| restore the view of the current window