1

Make a list of these words:

Če
Čeprav
Človeški
čaka
čakal
čakalne
čakati
časih
časovni
času
če

Select all: ggVG and sort them with case insensitive: :sort i

Če
Čeprav
Človeški
čaka
čakal
čakalne
čakati
časih
časovni
času
če

You may have already detected a problem... But let's compare it with lowering case and then sorting them:

First, convert it to lower case: ggVGgu. and then sort them: :sort. You get:

čaka
čakal
čakalne
čakati
časih
časovni
času
če
če <-- DIFFERENCE
čeprav <-- DIFFERENCE
človeški <-- DIFFERENCE

I was expecting no differences between the 2 methods, so I don't get why I have this inconsistency?

7
  • 1
    you might want to use sort l to use the current locale for sorting. Jun 27, 2021 at 17:24
  • 1
    That was it! Thanks a lot. I don't get why this isn't by default?
    – ThePhi
    Jun 27, 2021 at 17:30
  • 1
    @filbranden Try :lang collate sl_SI.
    – ThePhi
    Jun 27, 2021 at 17:41
  • 1
    @ThePhi please post an answer with what worked for you! Thanks!
    – filbranden
    Jun 27, 2021 at 19:32
  • 1
    Oh and welcome to Vi and Vim!
    – filbranden
    Jun 27, 2021 at 19:33

1 Answer 1

1

Since Vim release 8.2.0988, Vim supports sorting by the collation. That means, it uses your currently configured locale ($LC_COLLATE). Using the collation order also means, there are specific rules for sorting multi-byte characters for your configured locale.

If it is set, you can see by the output of :lang or using :echo v:collate.

So by setting your locale correctly you can sort using the :sort l parameter. Usually, sorting by the collation is also case insensitive, although that does not always have to be.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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