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
22
33
44 VIM REFERENCE MANUAL by Bram Moolenaar
@@ -20,6 +20,7 @@ commands with the "." command.
20205. Copying and moving text | copy-move |
21216. Formatting text | formatting |
22227. Sorting text | sorting |
23+ 8. Deduplicating text | deduplicating |
2324
2425For inserting text see | insert.txt | .
2526
@@ -1895,6 +1896,7 @@ And a few warnings:
18951896
18961897Vim has a sorting function and a sorting command. The sorting function can be
18971898found here: | sort() | , | uniq() | .
1899+ Also see | :uniq | .
18981900
18991901 *:sor* *:sort*
19001902:[range] sor[t][!] [b][f][i][l][n][o][r][u][x] [/{pattern} /]
@@ -1904,7 +1906,7 @@ found here: |sort()|, |uniq()|.
19041906 With [!] the order is reversed.
19051907
19061908 With [i] case is ignored.
1907-
1909+ *:sort-l*
19081910 With [l] sort uses the current collation locale.
19091911 Implementation details: strcoll() is used to compare
19101912 strings. See | :language | to check or set the collation
@@ -1937,13 +1939,14 @@ found here: |sort()|, |uniq()|.
19371939
19381940 With [b] sorting is done on the first binary number in
19391941 the line (after or inside a {pattern} match).
1940-
1942+ *:sort-u* *:sort-uniq*
19411943 With [u] (u stands for unique) only keep the first of
19421944 a sequence of identical lines (ignoring case when [i]
19431945 is used). Without this flag, a sequence of identical
19441946 lines will be kept in their original order.
19451947 Note that leading and trailing white space may cause
19461948 lines to be different.
1949+ When you just want to make things unique, use | :uniq | .
19471950
19481951 When /{pattern} / is specified and there is no [r] flag
19491952 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
19901993process you may end up with duplicated lines. This also depends on the system
19911994library function used.
19921995
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+
19932047 vim:tw=78:ts=8:noet:ft=help:norl:
0 commit comments