更新时间:2023-12-04 16:52:58
刚刚找到了解决方案 here 。以下正则表达式正确工作:
g / ^ \(。* \)$ \\\
\1 $ / d
This question already addresses how to remove duplicate lines, but enforces that the list is sorted first.
I would like to perform the remove contiguous duplicate lines step (i.e. uniq
) without first sorting them.
Example before:
Foo
Foo
Bar
Bar
Example after:
Foo
Bar
Just found the solution here. The following regex works correctly:
g/^\(.*\)$\n\1$/d