Emacs 24.4 introduces the command delete-duplicate-lines
.
By default M-x delete-duplicate-lines
will delete all but one copy
of any identical lines in the region. So assuming this is the region:
1 2 3 4 5 6 7 8 9 10 |
|
it will be reduced to this:
1 2 3 4 5 6 |
|
When the command is invoked with a C-u
prefix, it searches backwards
and keeps the last instance of each repeated line. So this:
1 2 3 4 5 6 7 8 9 10 |
|
will become:
1 2 3 4 5 6 |
|
Identical lines need not be adjacent, unless you’ve invoked the
command with a C-u C-u
prefix. When the command is invoked with a
C-u C-u C-u
prefix, it retains repeated blank lines.