|v:collate| can also used to check the current locale.
Sorting using the locale typically ignores case.
This does not work properly on Mac.
Options [n][f][x][o][b] are mutually exclusive.
With [n] sorting is done on the first decimal number
in the line (after or inside a {pattern} match).
One leading '-' is included in the number.
With [f] sorting is done on the Float in the line.
The value of Float is determined similar to passing
the text (after or inside a {pattern} match) to
str2float() function.
With [x] sorting is done on the first hexadecimal
number in the line (after or inside a {pattern}
match). A leading "0x" or "0X" is ignored.
One leading '-' is included in the number.
With [o] sorting is done on the first octal number in
the line (after or inside a {pattern} match).
With [b] sorting is done on the first binary number in
the line (after or inside a {pattern} match).
With [u] (u stands for unique) only keep the first of
a sequence of identical lines (ignoring case when [i]
is used). Without this flag, a sequence of identical
lines will be kept in their original order.
Note that leading and trailing white space may cause
lines to be different.
When /{pattern}/ is specified and there is no [r] flag
the text matched with {pattern} is skipped, so that
you sort on what comes after the match.
'ignorecase' applies to the pattern, but 'smartcase'
is not used.
Instead of the slash any non-letter can be used.
For example, to sort on the second comma-separated
field: >
:sort /[^,]*,/
< To sort on the text at virtual column 10 (thus
ignoring the difference between tabs and spaces): >
:sort /.*\%10v/
< To sort on the first number in the line, no matter
what is in front of it: >
:sort /.\{-}\ze\d/
< (Explanation: ".\{-}" matches any text, "\ze" sets the
end of the match and \d matches a digit.)
With [r] sorting is done on the matching {pattern}
instead of skipping past it as described above.
For example, to sort on only the first three letters
of each line: >
:sort /\a\a\a/ r
< If a {pattern} is used, any lines which don't have a
match for {pattern} are kept in their current order,
but separate from the lines which do match {pattern}.
If you sorted in reverse, they will be in reverse
order after the sorted lines, otherwise they will be
in their original order, right before the sorted
lines.
If {pattern} is empty (e.g. // is specified), the
last search pattern is used. This allows trying out
a pattern first.
Note that using `:sort` with `:global` doesn't sort the matching lines, it's
quite useless.
`:sort` does not use the current locale unless the l flag is used.
Vim does do a "stable" sort.
The sorting can be interrupted, but if you interrupt it too late in the
process you may end up with duplicated lines. This also depends on the system
library function used.
vim:tw=78:ts=8:noet:ft=help:norl: