Thursday, February 12, 2015

Sort numeric and literal columns in Vim

Sort normally:

:'<,'>sort

Sort numerically:

:'<,'>sort n

Sort on second column:

:'<,'>sort -k 2
:'<,'>sort /.*\%2v/

Sort and remove duplicated lines:

:'<,'>sort u

Reference:

http://stackoverflow.com/questions/1355004/how-to-sort-numeric-and-literal-columns-in-vim

No comments: