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


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.

code of conduct - report abuse