开发者

re-assign vim buffer number

I have vim buffers like this:

1 "file1.txt"
2 "file2.txt"
3 "fi开发者_Python百科le3.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?


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:

  • pull up file2.txt and hit 1<leader><C-6>
  • pull up file1.txt and hit 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜