1
- *change.txt* For Vim version 9.1. Last change: 2025 May 28
1
+ *change.txt* For Vim version 9.1. Last change: 2025 Jun 23
2
2
3
3
4
4
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -20,6 +20,7 @@ commands with the "." command.
20
20
5. Copying and moving text | copy-move |
21
21
6. Formatting text | formatting |
22
22
7. Sorting text | sorting |
23
+ 8. Deduplicating text | deduplicating |
23
24
24
25
For inserting text see | insert.txt | .
25
26
@@ -1895,6 +1896,7 @@ And a few warnings:
1895
1896
1896
1897
Vim has a sorting function and a sorting command. The sorting function can be
1897
1898
found here: | sort() | , | uniq() | .
1899
+ Also see | :uniq | .
1898
1900
1899
1901
*:sor* *:sort*
1900
1902
:[range] sor[t][!] [b][f][i][l][n][o][r][u][x] [/{pattern} /]
@@ -1904,7 +1906,7 @@ found here: |sort()|, |uniq()|.
1904
1906
With [!] the order is reversed.
1905
1907
1906
1908
With [i] case is ignored.
1907
-
1909
+ *:sort-l*
1908
1910
With [l] sort uses the current collation locale.
1909
1911
Implementation details: strcoll() is used to compare
1910
1912
strings. See | :language | to check or set the collation
@@ -1937,13 +1939,14 @@ found here: |sort()|, |uniq()|.
1937
1939
1938
1940
With [b] sorting is done on the first binary number in
1939
1941
the line (after or inside a {pattern} match).
1940
-
1942
+ *:sort-u* *:sort-uniq*
1941
1943
With [u] (u stands for unique) only keep the first of
1942
1944
a sequence of identical lines (ignoring case when [i]
1943
1945
is used). Without this flag, a sequence of identical
1944
1946
lines will be kept in their original order.
1945
1947
Note that leading and trailing white space may cause
1946
1948
lines to be different.
1949
+ When you just want to make things unique, use | :uniq | .
1947
1950
1948
1951
When /{pattern} / is specified and there is no [r] flag
1949
1952
the text matched with {pattern} is skipped, so that
@@ -1990,4 +1993,56 @@ The sorting can be interrupted, but if you interrupt it too late in the
1990
1993
process you may end up with duplicated lines. This also depends on the system
1991
1994
library function used.
1992
1995
1996
+ ==============================================================================
1997
+ 8. Deduplicating text *deduplicating* *unique*
1998
+
1999
+ Vim has a deduplicating function and a deduplicating command. The
2000
+ deduplicating function can be found here: | uniq() | .
2001
+ Also see | :sort-uniq | .
2002
+
2003
+ *:uni* *:uniq*
2004
+ :[range] uni[q][!] [i][l][r][u] [/{pattern} /]
2005
+ Remove duplicate lines that are adjacent to each other
2006
+ in [range] . When no range is given, all lines are
2007
+ processed.
2008
+
2009
+ With [i] case is ignored when comparing lines.
2010
+
2011
+ With [l] comparison uses the current collation locale.
2012
+ See | :sort-l | for more details.
2013
+
2014
+ With [r] comparison is done on the text that matches
2015
+ /{pattern} / instead of the full line.
2016
+
2017
+ When /{pattern} / is specified and [r] is not used, the
2018
+ text matched with {pattern} is skipped and comparison
2019
+ is done on what comes after the match.
2020
+ 'ignorecase' applies to the pattern, but 'smartcase'
2021
+ is not used.
2022
+
2023
+ Instead of the slash any non-letter can be used.
2024
+
2025
+ For example, to remove adjacent duplicate lines based
2026
+ on the second comma-separated field: >
2027
+ :uniq r /[^,]*,/
2028
+ < Or to keep only unique lines ignoring the first 5
2029
+ characters: >
2030
+ :uniq u /.\{5}/
2031
+ < If {pattern} is empty (e.g. // is used), the last
2032
+ search pattern is used.
2033
+
2034
+ With [u] only keep lines that do not repeat (i.e., are
2035
+ not immediately followed by the same line).
2036
+
2037
+ With [!] only keep lines that are immediately followed
2038
+ by a duplicate.
2039
+
2040
+ If both [!] and [u] are given, [u] is ignored and [!]
2041
+ takes effect.
2042
+
2043
+ Note that leading and trailing white space, and lines
2044
+ that are not adjacent, are not considered duplicates.
2045
+ To remove all duplicates regardless of position, use
2046
+ | :sort-u | or external tools.
2047
+
1993
2048
vim:tw=78:ts=8:noet:ft=help:norl:
0 commit comments