vim之删除重复行

重新排序,并且删除重复的行(只保留一行)。

:sort u

删除连续相同的行,保留最后一行。

g/^\(.*\)$\n\1$/d

删除连续相同的行,保留最初一行。

g/\%(^\1$\n\)\@<=\(.*\)$/d

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>