Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Suppose I have a file with the following content:

c
C
b
B
a
A

When I do :%sort, I get the following result:

A
B
C
a
b
c

When I do :%!sort (note the '!'), I get

a
A
b
B
c
C

I get the same behaviour with regular expressions, i.e. [A-Z] inside VIM matches uppercase characters and not [aAbBcC...].

The output of "locale":

LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

The output of :language inside VIM:

Current language: 
"LC_CTYPE=en_US.UTF-8;
LC_NUMERIC=C;
LC_TIME=en_US.UTF-8;
LC_COLLATE=en_US.UTF-8;
LC_MONETARY=en_US.UTF-8;
LC_MESSAGES=en_US.UTF-8;
LC_PAPER=en_US.UTF-8;
LC_NAME=en_US.UTF-8;
LC_ADDRESS=en_US.UTF-8;
LC_TELEPHONE=en_US.UTF-8;
LC_MEASUREMENT=en_US.UTF-8;
LC_IDENTIFICATION=en_US.UTF-8"

According to ":language" vim should be using "utf8 sorting", but apparently it doesn't.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

From VIM 7.3 ':help sort'

The details about sorting depend on the library function used.  There is no
guarantee that sorting is "stable" or obeys the current locale.  You will have
to try it out.
share|improve this answer

(1) I know that this is not really an answer to the main question that was asked, and (2) I don't have access to vim right now, so all I can be sure of is that this works for vi.  That said, you can get vi to do case-insensitive searches by typing :set ignorecase (or :set ic for short, or :se ic for shorter).  Use :set noic to revert to case-sensitive behavior.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.