Sort lines
:sort
Example
Normal 0 / 2Command-line 1 / 2Normal 2 / 2pear
apple
bananaCursor on line 1, column 1pear
apple
bananaCursor on line 1, column 1apple
banana
pearCursor on line 1, column 1Sort lines.
Command entered · ready to apply
Sort lines
Before & after
pear
apple
bananaCursor on line 1, column 1apple
banana
pearCursor on line 1, column 1Start in Normal mode. The buttons include the concrete range and arguments used for this example; press Enter to execute. Indentation uses expandtab and shiftwidth=2.
Details & Vim help
Example replayed in Vim
Sort lines. This Ex reference uses the full command name; the alphabetical index omits arguments. Supply the ranges, arguments, flags and prerequisite state documented in the linked help. Press Enter to submit a complete command. The index spelling :sor[t] puts the optional abbreviation suffix in square brackets; those brackets are not typed. Availability and exact behavior can depend on Vim build features, options, mappings and editor state; the linked help is authoritative.