Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sorting lines with vim by lines chunk

Tags:

vim

sorting

lines

Can I sort lines in vim depending on a part of line and not the complete line? e.g

My Name is Deus Deceit

I would like to sort depending on the column that the name starts + 6 columns for example sort by column 19-25 and vim will only check those characters for sorting. If it can be done without a plugin that would be great. ty

like image 249
Not Amused Avatar asked Nov 30 '25 20:11

Not Amused


1 Answers

Check out :help :sort. The command takes an options {pattern} whose matched text is skipped (i.e. sorting happens after the match.

For example, to sort by column 19+ (see :help /\%c and the related regexp atoms):

:sort /.*\%19c/
like image 69
Ingo Karkat Avatar answered Dec 02 '25 08:12

Ingo Karkat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!