On Wed, Apr 01, at 01:07 guwegezo wrote: > > Is it possible to sort the buffer list in Vim? > > I commonly work with 10-20 files open. They tend to be groups of files > from different paths within my project. When I issue :ls, it's often > difficult to find the file I'm looking for. Sorting the buffer list > would help a great deal.
Here is a possible way, function! Bufnames(A, L, P) redir => bufnames silent ls redir END let list = [] for name in split(bufnames, "\n") let buf = fnamemodify(split(name, '"')[-2], ":t") if match(buf, "No Name") == -1 call add(list, buf) endif endfor return filter(sort(list), 'v:val =~ "^".a:A') endfunction command! -nargs=1 -complete=customlist,Bufnames Myls exec "buffer "<q-args> Now use: :Myls<tab> or :Myls<Control-D> or :Myls [first letter from a buffer name] for a custom completion. > Douglas. Regards, Agathoklis. --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---