Hacker News new | past | comments | ask | show | jobs | submit login

To all the vim people I have one question: how do you deal with multiple buffers?

I'm so attached to the emacs way of buffer handling that I just can't get comfortable with vim. It's really the one thing that I just don't get in vim.




I find these two options a must (they're in my .vimrc):

set hidden

set switchbuf=useopen

Beyond that I just use the basic commands to navigate buffers: :ls, :b, :bl, and ctrl-^

Ctrl-^ (switch to the "alternate" (previous) file) is the one a I use the most really. Especially since windows each have their own alternate file.

Generally, I find remembering buffer numbers in a long-running session no more difficult than remembering inventory letters in Angband ;-)


I map H and L to custom functions that navigate to the next or previous tab or buffer, depending on what's open.

https://github.com/mcantor/dotfiles/blob/master/vim/.vimrc#L...


I have F5 bound to :bn , it let me roll buffers, then I use :bd to remove a buffer. I open new files with :Explore.


The problem I have it that C-x-b defaults to jumping back to the previous buffer. So I can just bang C-x-b<RET> and be back to where I was before. I can't find the same thing with vim.

It's a very rare use case for me to want to roll through all the open buffers.


You can use :ls to view all buffers, and if you do :b and start typing the filename of a buffer, you can get completion suggestions with tab, or just hit enter to jump to the first file that matches what you've typed so far.

Use Ctrl-6 (also referred to as Ctrl-^, C-6 or C-^) to swap between your current buffer and the "alternate" buffer, which is usually the last buffer you were looking at.

Use Ctrl-o and Ctrl-i to track up and down the "jump list". C-o is another good way to get back to the buffer you were just looking at, like C-6.


There is also a wealth of plugins for buffer switching; I like FuzzyFinder's :FufBuffer command. Invoke it and the most recent buffer will be at the top, so you can hit enter immediately.


I never really saw the utility of the plugins. The functionality you described in your post, for example, is already implemented by C-6.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: