I know that in vim I can sort the file using a regular expression to indicate which parts of each line that I want to use for consideration when sorting using:
:sort 'regex' r
Is it possible to combine more than one expression?
Here you have an example:
INPUT:
bar a 2 foo b 1 bar b 1 foo a 2
: sort '[az]' r
foo b 1 bar b 1 bar a 2 foo a 2
sort '[0-9]' r
bar a 2 bar b 1 foo b 1 foo a 2
EXPECTED (maybe something like ": sort" [AZ] | [0-9] 'r?):
bar b 1 bar a 2 foo b 1 foo a 2
Note that bare βsortingβ does not work due to βaβ and βbβ, which upset the numbers
bar a 2 bar b 1 foo a 2 foo b 1
An alternative outside VIM is also accepted, but for the sake of curiosity, I would like to know if it is really possible to do this in VIM (and if afermative, how ;-)
Thanks a lot, Relations
sorting vim regex
Carles sala
source share