如果有重复行,保留最后一行,删除前面的相同行
:g/^\(.*\)$\n\1$/d
如果有重复行,保留最前面的行,删除后面的相同行
:g/\%(^\1$\n\)\@<=\(.*\)$/d
g//d <-- Delete the lines matching the regexp
\@<= <-- If the bit following matches, make sure the bit preceding this symbol directly precedes the match
\(.*\)$ <-- Match the line into subst register 1
\%( ) <--- Group without placing in a subst register.
^\1$\n <--- Match subst register 1 followed by end of line and the new line between the 2 lines
阅读(1617) | 评论(0) | 转发(0) |