Vim: Changing Buffer Numbers

"the buffer numbers get crazy" Tell me about it! By the end of the day I'm easy over 100 buffers. But luckily, as you can see in this animation, you have tab completion for buffer names.

Hit :b se<Tab>

So, even though you can't renumber the buffers, you can still jump around easily.

It's also worth noting that it is doing *str* matching so I didn't have to search on "se" to go straight to that file. Typing :b uptab would have also taken me straight there. If there are more than one match, subsequent tabs will cycle over the matches (circularly). So, in this session I could cycle over my "test" files or my "py" files if I wished. This is BETTER than renumbering once you learn it!


I think I figured out a way to do this. Use mksession: {session_filename}, close out your session, open {session_filename}, Look for the lines with badd {filename}, add/edit/delete/arrange these lines, then open it again with vim -S {session_filename}. The buffers will be in the new order. Be careful with deleting if it was a current or active file. I will be referenced in other places.


It is not possible to assign buffer numbers manually, or reassign them for that matter. The only way to restart buffer numbering is to restart vim. You might be interested in the SelectBuf script.

Tags:

Vim

Buffer