3

How to sort the list of buffers Vim displays on entering :b <Tab> by most recent?

I'm used to the Spacemacs ordering, which displays buffer filenames in separate rows (vertically) in the order of most recent access.

I like accessing files by autocompleting the filename, so :ls is not an option. I do not interact with buffers in other ways, so I'm fine with breaking things or using plugins. I already use fzf.vim.

There were some similar questions, but nothing directly relevant to my problem.

  • 1
    can you explain what you mean by "after :b" and "displaying vertically?" – Mass Jun 10 '21 at 00:18
  • 1
    Sorry, it is actually after :b <Tab>. – Daniel Paleka Jun 10 '21 at 00:33
  • This does not answer your question, but I have two recommendations for your cases: bufexplorer for viewing buffers; They are ordered by last used by default. Then ctrl-p for a fuzzy file finder. Super easy to use and even more useful. – earthling Jun 10 '21 at 06:09
  • Pretty sure tab completion of buffers is core, non-configurable functionality, i.e. short of someone basically (re)implementing something similar in vimscript you're stuck with lexicographical ordering. – B Layer Jun 10 '21 at 10:09
  • Actually, looking at the accepted answer found through the third link you provided, which pretty much says what I said about tab completion ordering...you're not going to get any substantially different answer here. At least not without expanding your horizons beyond just tab completion. (FYI, the author was a major contributor here, too, and knows what they're talking about.) – B Layer Jun 10 '21 at 18:04
  • Yeah, but something might have changed since 2011. I found something good enough: fzf.vim default settings bind <Leader> b to a list of buffers ordered by most recent, and tab-completion works. Could I bind :b to that? – Daniel Paleka Jun 10 '21 at 18:22
  • A Normal mode mapping? Yes, but there will be some delay (configurable) when you want to go to the command line with :. Or do you mean map just b from command-line context? You can do that but I think you'll want to map it a particular way so you don't pick up any old b on the command line. – B Layer Jun 11 '21 at 20:25
  • This (both my answer and some of the comments) have enough information to create the kind of command-line mapping I'm referring to. There's a lot of noise so what you'll be primarily interested in is the cnoremap in the second update. How to jump to buffer from ls? – B Layer Jun 11 '21 at 20:45

0 Answers0