5 ms·
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 bu
by anonymous 14y ago
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.
- mbudde 14y agoYou can if you enable the 'hidden' option.
- johncoltrane 14y agoThat'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.
- anonymous 14y agoThanks! But it's too late for me - I already switched to emacs + evil-mode.
- zmanji 14y agoAny suggestions on getting started with emacs and evil?
- AlexFromBelgium 14y agoTo bad switchbuf doesn't actually work with :b. Only buffer related split commands like :sbuffer, :sbnext
- johncoltrane 14y agoargh. :sb indeed.
- Symmetry 14y agoYup. The problem with vim is that it has way too many buttons you have to press to unbreak it.
- tyrmored 14y agoHmm, 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.
- m0shen 14y agoHe 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 http://vim.wikia.com/wiki/Vim_buffer_FAQ
- tyrmored 14y agoThanks for that; I clarified and gave you a footnote.
- m0shen 14y agoNp, 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 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/ http://kien.github.com/ctrlp.vim/ ) works well for searching them.
- Vitaly 14y agonot 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.