What's the difference between a pane, buffer and tab in Vim and how should they be used in one's workflow?

twitter logo github logo ・1 min read

I still consider myself a newb when it comes to using Vim and still trying to optimize my workflow. One of those is trying to figure out what the differences are between a pane, buffer and tab in Vim and how should they be used in one's workflow?

twitter logo DISCUSS (8)
markdown guide

When you open a file, the file is loaded into memory, into a buffer. I think of the buffers as basically a cache for the filesystem. If you switch to another file and then switch back, the other file is still loaded into a buffer, so it doesn't need to be reloaded off disk. A buffer also serves as a place to store your unsaved changes. There's never more than one buffer per file. I don't usually think about buffers, since they're just files cached in memory.

A pane is what actually displays the contents of a file. For me, the most common arrangement is to have one pane taking up the whole screen, displaying one file. Sometimes I split the screen, displaying one file on each half. Occasionally I open a new tab and put a file or two in it. I do this to keep the file around, so I can see it's still there and switch to it after a while.

Most of my file navigation is done with ctrl-p. I press ctrl-p, type the name of the file I want, and press enter, and the file is loaded into the current pane. I also use ctrl-] a lot, which is basically "go to definition" once you've set up ctags (gutentags ftw). I put the cursor on the name of a function, press ctrl-], and the definition of the function is loaded into the current pane.


Nice, thanks @tbodt for sharing your workflow. By CTRL-P are you referring to this?


Cool, thanks, will look into it. I take it you use this versus something like NerdTree?

Yeah, I don't use NerdTree. I prefer to hold the structure of my project's files in my head, and just type what I want. I occasionally use netrw (vim's builtin NerdTree equivalent) to browse file trees, but more often just use the Finder.

Nice, yeah I've been using NerdTree but thinking of removing it. Since the use of NerdTree was to replicate my experience in Atom. But I'm finding the workflow to be a little slow.

Are you using NerdTree to navigate between files? Yeah, give ctrlp a try and see if it feels faster.

Yup, that's right. It's for file navigation. Vim isn't my first choice for text editing but always looking to improve my workflow when I do.

Classic DEV Post from Jun 20 '19

Do you use time-tracking for work or for your personal time?

Michael Lee 🍕 profile image
Maker of things, giver of high-fives 🖐

dev.to now has dark theme. 🌝

Go to the "misc" section of your settings and select night theme

P.S. You can also change font to sans serif, which a lot of folks prefer. 💖

P.P.S. It's also the best place to talk code amongst thoughtful developers, and it's totally open source