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:

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