When I need to work on different projects at the same time I have the folowing workflow:
- I create one tab for each project.
- In each tab I open the files that I want to edit, which makes several buffers.
- Optionnaly if I need to see two (or more) files at the same time I create split windows so I have a tab containing different windows which shows one buffer.
To navigate between my buffers I don't really use :ls
and :b [name or number of buffer]
instead I created some convenient mappings allowing me to switch between the buffers with :bnext
and :bprevious
This way to work is pretty good but something bothers me: the buffers are shared between the tabs.
If I open file1
and file2
in tab1
and file3
in tab2
, if in tab1
I use several time :bnext
I'll see file3
in this tab which I don't want to. The workflow I'd want to get is the folowing:
- Start vim (I have a first tab with a buffer in it):
$ vim foo
- Add a buffer to this tab:
:e bar
- Open a new tab and switch to it:
:tabnew
- Open a new buffer in this tab:
:e baz
- If I stay in this buffer and do
:bnext
or:bprevious
I'll stay onbaz
buffer (since it is the only one in this tab) - If I go in the previous tab
:tabprevious
and execute several time:bnext
I'll switch only betweenfoo
andbar
buffers but will not seebaz
So here comes my question: Is it possible to bind a set of buffers to a tab and make vim disallow the access to some buffers from another tab than the one they're meant to be in?
Note: I'm aware that using :b [myBuffer]
would be a way to keep a buffer in a tab but when I have 3 or 4 files to edit I feel like I'm really faster using my mappings than typing the buffer name (even if I can type only some characters to match the buffer name).
alt+tab
(or even worse the mouse) feels much less easy than switching tab within vim.