Sort numerically in VI editor [duplicate]

Just use Vim’s own sort function. Visually highlight the text (or use a range) and type:

:sort n

Documentation is available here: http://vim.wikia.com/wiki/Sort_lines

Or in Vim itself: :help sort

(Edited to reflect an important point of clarification from dash-tom-bang and the reference to Vim’s own help file.)

Leave a Comment