11

As I open up new files inside vim, the buffer index seems to skip over arbitrary indices. I switch between buffers using b<buffer-index>, so it helps to have sequential indices for sanity/OCD sake. After a while, I just exit vim and load up the files I'm currently working on via CL and it orders them sequentially, but this is a pain when you have multiple sub-directory paths.

Can I reset the sequence or something?

2 Answers 2

13

No, not without restarting Vim. There are a number of reasons why they cannot be reset, some of them internal, some having to do with avoiding surprises with Vim scripts that store buffer numbers.

Are you aware that you can do :buffer some_partial_buffer_name to jump to another buffer, as long as the string you supply (some_partial_buffer_name) is unique?

3
  • 2
    Ah! Thanks for the tip, I didn't know :buffer worked with partial names.
    – leo
    Dec 27, 2011 at 20:41
  • vim-airline uses pseudo- buffer numbers then.
    – Paschalis
    Apr 5, 2016 at 8:06
  • You can type :b minimal_unambigous_portion_of_some_buffer_path and then hit <kbd>Tab</kbd> too. Nov 21, 2020 at 19:00
4

Creating a session (:mksession!), closing vim and opening the session (:so Session.vim) will reorder you indices starting from 2 (1 is used to source the session).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .