I had thought vim was all powerful until I wanted to get rid of buffers in the list and reuse them for something else. For example, if I have
1 "f1.h" 2 "f2.h" 3 "f3.h" 4 "f1.cpp" 5 "f2.cpp" 6 "f3.cpp"
and I want to replace f1.h - f3.h with something else, but in the same buffer sequence:
1 "n1.h" 2 "n2.h" 3 "n3.h" 4 "f1.cpp" 5 "f2.cpp" 6 "f3.cpp"
I can't figure out how to do it. I can do "1,3bd" and delete buffers 1-3, or even "1,3bw" and wipe them out, but don't see any way to reuse those numbers without restarting vim. The vim buffer faq at http://vim.wikia.com/wiki/Vim_buffer_FAQ appears to confirm this.
But I don't want to believe that vim really has this limitation, is there really no way to do this from within vim?
You can't reassign buffer numbers in the same session. Your best bet is to look around at vimscript alternatives.
One buffer explorer that handles sorting to most recent used files (and can delete buffers) is Buffer Explorer / Browser.
There are loads of other buffer switching scripts on vim.org that cater to their various authors needs. Or alternatively you could roll your own with some mappings.
I came up with this for Django.
http://code.djangoproject.com/wiki/UsingVimWithDjango#Mappings
It gives me quick two/three keystroke access to 20 standard named files relative to an app directory. You could come up with something for your project on these lines.
My mappings are \1
, \2
, \3
etc so the number paradigm is still there.
I also mapped \vr
for ~/.vimrc and \br
for ~/.bashrc.
The important thing it can and should be a very efficient process.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With