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

Re: Sort the buffer list

Expand Messages
  • Christian Brabandt
    ... Does that work? fu! MyLS() redir = bufnames silent ls redir END let list = [] let list = split(bufnames, n ) echo n . join(sort(list, MyCompare ),
    Message 1 of 4 , Apr 1, 2009
      On Thu, April 2, 2009 4:51 am, guwegezo wrote:
      > Impressive, but not quite what I had in mind. Are you able to modify
      > the function so that it simply displays the sorted output of :ls? Then
      > I could map it to :Ls.

      Does that work?

      fu! MyLS()
      redir => bufnames
      silent ls
      redir END
      let list = []
      let list = split(bufnames, "\n")
      echo "\n" . join(sort(list, "MyCompare"), "\n")
      endfunction

      fu! MyCompare(...)
      let dict={}
      for name in a:000
      let dict[name]=fnamemodify(split(name, '"')[-2], ":t")
      endfor
      return dict[a:1] == dict[a:2] ? 0 : dict[a:1] > dict[a:2] ? 1 : -1
      endfunc

      command! -nargs=0 Ls :call MyLS()


      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    Your message has been successfully submitted and would be delivered to recipients shortly.