Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to effectively manage tabs / buffers in vim?

Tags:

vim

tabs

buffer

This is how I use vim's tabs:

enter image description here

I have shortcuts to move a tab to left/right with <ctrl>j <ctrl>k and to move between tabs with <ctrl>h, <ctrl>l. According to answer to this question, I'm doing it wrong. How to effectively use buffers then? Constantly listing hidden buffers to know which to switch to doesn't seem like an imprevement.

like image 760
user1367401 Avatar asked Sep 20 '12 15:09

user1367401


1 Answers

There is no right or wrong way of handling buffers in Vim. First, learn and understand the difference between buffers, windows, and tab pages. Then adopt a style that suits you. There are many "buffer management" plugins on http://www.vim.org/, but you can also just use the built-in commands like :buffer together with file completion.

If you solely stick to the "one file per tab" rule (like in a browser), you're losing the benefits of window splits, and you'll still occasionally encounter splits in the form of the preview and quickfix windows, and in order to use diff mode.

I mostly use tab pages to separate different workspaces (I only have a single GVIM instance running); sometimes I open the same set of buffers in different tabs in different arrangements, like the perspectives in IDEs such as Eclipse.

like image 195
Ingo Karkat Avatar answered Nov 10 '22 21:11

Ingo Karkat