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  
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,56 @@ 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+ 			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+ 
19932048 vim:tw=78:ts=8:noet:ft=help:norl:
0 commit comments