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```
#打賞
如果這篇文章解決了您的問題,讓我買根煙抽抽涂乌。
![支付寶.jpg](http://upload-images.jianshu.io/upload_images/4765606-b13a42b44fd975a7.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/340)
![微信.jpg](http://upload-images.jianshu.io/upload_images/4765606-3ad5592b17125067.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/340)