我有一个包含以下行的文件:
one one
one one
two two two
one one
three three
one one
three three
four
我想从文件中删除所有出现的重复行,只留下非重复行。因此,在上面的示例中,结果应该是:
two two two
four
我看到了一个类似问题的答案。我试图修改 ex one-liner,如下所示:
:syn clear Repeat | g/^\(.*\)\n\ze\%(.*\n\)*\1$/exe 'syn match Repeat "^' . escape(getline ('.'), '".\^$*[]') . '$"' | d
但它不会删除所有出现的重复行,它只会删除一些出现。
我怎样才能在 vim 中做到这一点?或者特别是如何在 vim 中使用 ex 执行此操作?
为了澄清,我不是在寻找sort u
.