EasyVCR的专栏

Blogging...不知道这次能坚持写多久~

VIM 删除重复行 (VIM Remove duplicate lines)

//    http://vim.wikia.com/wiki/Uniq_-_Removing_duplicate_lines

:sort u

or

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

or

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

This does a uniq on the first word in the line, and deletes all but the first line: 

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

阅读更多
文章标签: vim delete
个人分类: Vim Tips
想对作者说点什么? 我来说一句

vim重复

:sort :sor ur /^/

drbinzhao drbinzhao

2017-02-12 04:51:58

阅读数:781

没有更多推荐了,返回首页

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭