Vim / Neovim enables us to manipulate text in various ways, in which, for example, we can sort lines or make them unique. Here are the examples.
Sort
Use sort
command.
Besides, here is the documentation of Vim / Neovim.
Specify sort order
1. ASC
By default.
:%sort
2. DESC
Append !
.
:%sort!
3. Numeric sort
Give n
as a parameter.
:%sort n
Specify sort range
1. Whole text
Use %
as usual.
:%sort
2. Specific lines only
Add startNum,endNum
to the head.
2-5 lines only, for example:
:2,5sort
3. Visual selection
As is.
:'<, '>sort
An example of order + range (combination)
Here is a DESC + numeric sort example.
:%sort! n
Make lines unique
Use sort
command as well. Give it u
as a parameter.
:%sort u