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 26
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,55 @@ 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
+ With [u] only keep lines that do not repeat (i.e., are
2018
+ not immediately followed by the same line).
2019
+
2020
+ With [!] only keep lines that are immediately followed
2021
+ by a duplicate.
2022
+
2023
+ If both [!] and [u] are given, [u] is ignored and [!]
2024
+ takes effect.
2025
+
2026
+ When /{pattern} / is specified and [r] is not used, the
2027
+ text matched with {pattern} is skipped and comparison
2028
+ is done on what comes after the match.
2029
+ 'ignorecase' applies to the pattern, but 'smartcase'
2030
+ is not used.
2031
+ Instead of the slash any non-letter can be used.
2032
+
2033
+ For example, to remove adjacent duplicate lines based
2034
+ on the second comma-separated field: >
2035
+ :uniq /[^,]*,/
2036
+ < Or to keep only unique lines ignoring the first 5
2037
+ characters: >
2038
+ :uniq u /.\{5}/
2039
+ < If {pattern} is empty (e.g. // is used), the last
2040
+ search pattern is used.
2041
+
2042
+ Note that leading and trailing white space may cause
2043
+ lines to be considered different.
2044
+ To remove all duplicates regardless of position, use
2045
+ | :sort-u | or external tools.
2046
+
1993
2047
vim:tw=78:ts=8:noet:ft=help:norl:
0 commit comments