Loading ...
Sorry, an error occurred while loading the content.
 

Re: Sort a set of lines

Expand Messages
  • Tim Chase
    ... It will work on Windows/Dos as well, as there s a sort command there as well...a tad more braindead, as it doesn t allow for all the nice parameters you
    Message 1 of 5 , Nov 2, 2005
      > Otherwise, on unix, a simple
      > :'<,'>!sort sould do it.

      It will work on Windows/Dos as well, as there's a "sort" command there
      as well...a tad more braindead, as it doesn't allow for all the nice
      parameters you can pass to unix/gnu "sort", but for simple
      alpha-sorting, it will suffice. If you want numerical sorting or sorting
      by characters other than in the first position, you'll likely have to
      install cygwin or one of the other ports of GNU tools to Win32.

      -tim
    • Charles E. Campbell, Jr.
      ... Well, tip 588 refers to http://mysite.verizon.net/astronaut/vim/index.html#VimFuncs (see Visual Block Sorting -- the topics are in alphabetical order).
      Message 2 of 5 , Nov 2, 2005
        Giorgos Gaganis wrote:

        > I would like to sort a few lines in a buffer. I have looked at tip
        > #588 but didn't help me much because I couldn't find the scripts it
        > refers to.
        > Any help would be greatly appreciated.

        Well, tip 588 refers to
        http://mysite.verizon.net/astronaut/vim/index.html#VimFuncs (see "Visual
        Block Sorting" -- the topics are in alphabetical order). The original
        tip refers to my old website; you'd have to look at the "Additional
        Notes" to see the new website, as we cannot edit our tips. Wish we
        could! That said, the tip is referring to using visual block-based
        based sorting (ie. use ctrl-v to select a rectangular region). One can
        sort lines based on just the text in a column, or sort just the contents
        of the column (leaving the text outside of the column alone).

        It seems you want to do some straight sorting of whole lines. If you
        have a decent external sort program, perhaps
        :[range]!sort
        where you pick the range (ie. :25,43!sort to sort lines 25-43
        inclusive). If you happen to be using vim 7.0, then the built-in sort
        command is available:
        :[range]sort

        Regards,
        Chip Campbell
      Your message has been successfully submitted and would be delivered to recipients shortly.