I have vim buffers like this:
1 "file1.txt"
2 "file2.txt"
3 "file3.txt"
and I want re-assign buffer numbers like this:
1 "file2.txt"
2 "file1.txt"
3 "file3.txt"
How do I do this?
From :help :ls:
Each buffer has a unique number. That number will not change, so you can always go to a specific buffer with ":buffer N" or "N CTRL-^", where N is the buffer number.
Why do you need to reassign those numbers? Maybe there is another thing to do to help you in your task?
:args and :argdo commands, from windowing and tabbing. All of them.#vim channel) who will be happy to help you for any problem you might have.While it is true that you can't technically re-assign buffer numbers there is this plugin that allows you to act like you can:
https://github.com/gelus/vim-buffer-enhancement
it allows you to map buffers to numbers by hitting <count><leader><C-6>
Then returning to the mapped buffers in the same way you switch to a regular buffer <count><C-6>
so for your example:
1<leader><C-6>2<leader><C-6>file3 is already at buffer 3, ( you can map it if you want, but it would work the same )
now hitting 1<C-6> will take you to file2.txt, 2<C-6> will take you to file1.txt and 3<C-6> will still take you to file3.txt