Vim has a very powerful built-in sort utility, or it can interface with an external one. In order to keep only unique lines in Vim, you would:
:{range}sort u```
Yes, it's that simple.
**Examples**
- Sort in reverse
```:%sort!```
- Sort, removing duplicate lines
```:%sort u```
- Sort using the external Unix sort utility, respecting month-name order
```:%!sort -M```
("respecting month-name order" means January < February < ... < December)
- Numeric sort
```:sort n```
(this way, 100 doesn't precede 20 in the sort)
- Sort subsections independently, in this example sort numbers between "start" and "end" markers
```:g/start/+1,/end/-1 sort n```
#打賞
如果這篇文章解決了您的問題,讓我買根煙抽抽涂乌。

