Alphabetical lines of a given range in vim

I have some lines that I want alphabetically. For example, let's say I have a vim set command in a file:

 set nowrap set number set expandtab set hlsearch set list 

How would I alphabetically write these 5 lines? The result will look like this:

 set expandtab set hlsearch set list set nowrap set number 
+5
source share
1 answer

The vim :sort command accepts a range of command line and allows you to use a regular expression to select a sort. You can also use an external sort command in the same way using :{range}!sort In my case :1,5sort does what I want. Additional help with the command :sort is available in this vim help topic:

:help :sort

+10
source

Source: https://habr.com/ru/post/1212754/


All Articles