Case insensitive sorting

10,895

Vim's own :sort command

:%sort i

does what you want.

See :help :sort.

Alternatively, you can also use your system's sort command as a filter:

:%!sort -f

See :help filter in Vim and $ man sort in your shell.

Share:
10,895

Related videos on Youtube

Oliver Salzburg
Author by

Oliver Salzburg

Updated on September 18, 2022

Comments

  • Oliver Salzburg
    Oliver Salzburg over 1 year

    Vim's default sort is case sensitive, and produces results like this:

    A
    B
    a
    

    How can it be made case-insensitive, to produce the following result given the same input?

    A
    a
    B
    
    • Hastur
      Hastur almost 10 years
      what about to use sort -f eventually redirecting output to a new file sort -f old_file > new_file?
    • FDinoff
      FDinoff almost 10 years
      I assume you mean case sensitive in the first one?
  • Deqing
    Deqing almost 6 years
    What's different between :%sort i and :sort i?
  • romainl
    romainl almost 6 years
    No fundamental difference. The former is explicit about the range on which it operates on while the latter is implicit.