News for hackers. Stuff that matters.
Re:Vim: Buffers, Windows, and Tabs by anonymous on Saturday June 09, 2012 @04:38AM (#4087619)
His explanation on buffers isn't completely true, though. You can't have an unsaved non-visible buffer. Meaning, if you edit a buffer, you can't open another buffer in the same window without saving the edited one, first.
Re:Vim: Buffers, Windows, and Tabs by johncoltrane on Saturday June 09, 2012 @05:27AM (#4087706)
That's why so many new users turn to using tabs. Because they think they can't replace the current unsaved buffer they open another file in a tab. The result is very superficially similar to what you'd get in other editors but it is very different and full of pitfalls if you persist in treating them as regular tabs.

These two lines in your ~/.vimrc are enough to be able to work efficiently with buffers and windows and make tabs more useable:

    set hidden
    set switchbuf=useopen,usetab
The first makes it possible to replace the current unsaved buffer with another one.

The second allows you to jump to a buffer where it is (in another window, another tab) instead of replacing the current buffer with :b buffername.

Re:Vim: Buffers, Windows, and Tabs by anonymous on Saturday June 09, 2012 @06:06AM (#4087757)
Thanks! But it's too late for me - I already switched to emacs + evil-mode.
Re:Vim: Buffers, Windows, and Tabs by zmanji on Saturday June 09, 2012 @08:47PM (#4089805)
Any suggestions on getting started with emacs and evil?
Re:Vim: Buffers, Windows, and Tabs by AlexFromBelgium on Saturday June 09, 2012 @09:41AM (#4088069)
To bad switchbuf doesn't actually work with :b.

Only buffer related split commands like :sbuffer, :sbnext

Re:Vim: Buffers, Windows, and Tabs by johncoltrane on Saturday June 09, 2012 @11:17AM (#4088269)
argh. :sb indeed.
Re:Vim: Buffers, Windows, and Tabs by Symmetry on Saturday June 09, 2012 @09:54AM (#4088098)
Yup. The problem with vim is that it has way too many buttons you have to press to unbreak it.
Re:Vim: Buffers, Windows, and Tabs by mbudde on Saturday June 09, 2012 @04:48AM (#4087637)
You can if you enable the 'hidden' option.
Re:Vim: Buffers, Windows, and Tabs by tyrmored on Saturday June 09, 2012 @05:41AM (#4087734)
Hmm, yes. :set hidden is recommended so often in pretty much every introductory tutorial that in places I've assumed people who have basic familiarity with Vim are already using it.

In retrospect this probably wasn't wise of me; I don't use it myself, and I still run into the occasional Vim guru online who doesn't either.

I've edited the post with a clarifying note and given you a footnote. Thanks.

Re:Vim: Buffers, Windows, and Tabs by m0shen on Saturday June 09, 2012 @10:14AM (#4088141)
He also says:

  It only goes away when you explicitly delete it with a call to :quit or :bdelete.
This isn't true. :bdelete makes the buffer an unlisted-buffer. :bwipeout actually removes the buffer completely.

http://vim.wikia.com/wiki/Vim_buffer_FAQ

Re:Vim: Buffers, Windows, and Tabs by tyrmored on Saturday June 09, 2012 @09:02PM (#4089836)
Thanks for that; I clarified and gave you a footnote.
Re:Vim: Buffers, Windows, and Tabs by m0shen on Sunday June 10, 2012 @11:19AM (#4091262)
Np, it took me an embarrassingly long amount of time to grok Vims handling of Buffers, Tabs and Windows. I think your article is a nice introductory writeup on the subject. I wish I had it when I first started with Vim.

Also, as far as buffer handling goes, I really like the SelectBuf ( http://www.vim.org/scripts/script.php?script_id=107 ) plugin for listing and sorting open buffers ( including unlisted! ). CtrlP ( http://kien.github.com/ctrlp.vim/ ) works well for searching them.

Re:Vim: Buffers, Windows, and Tabs by Vitaly on Saturday June 09, 2012 @02:20PM (#4088788)
not true. well, it kind of is if you don't configure your vim "right". any sensible configuration I've seen includes the "set hidden" option which will enable you to switch to another buffer w/o saving the current one. w/o this config option vim is barely usable imho.