marijnh/CodeMirror — pull request #1566 by mightyguava (2013-06-01 14:29:35+00:00)
Title: [vim] Add support for :sort

Supports all options except [r] and [/pattern}/].
```
*:sor* *:sort*
:[range]sor[t][!] [i][u][r][n][x][o] [/{pattern}/]
Sort lines in [range]. When no range is given all
lines are sorted.

With [!] the order is reversed.

With [i] case is ignored.

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 [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 [u] 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.
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.
```