Sorting on two columns in vim
sorting, vim
Solution
This can be done using an external (GNU) sort pretty straightforwardly:
!sort -t ';' -k 2,2n -k 3,3n
This says: split fields by semicolon, sort by 2nd field numerically, then by 3rd field numerically. Probably a lot easier to read and remember than whatever vim-internal command you can cook up.
Much more info on GNU sort here: http://www.gnu.org/software/coreutils/manual/html_node/sort-invocation.html
Problem
I have a table that looks something like this: ``` FirstName SurName;Length;Weight; ``` I need to sort on length, and if the length is equal for one or more names, I need to sort those on weight. `sort ni` sorts only on length, I tried `sort /.\{-}\ze\dd/` that too, but that didn't work either. Any help would be greatly appreciated!