Is it possible to create 2 tabs in VIM with separate buffers?

I mostly work on a website and sometimes I need to have 3 or 4 buffers displayed for the backend and 3 or 4 buffers for the interface at the same time. There are tabs here, but the buffers are mixed. I know I'm a bit fussy, but is there a way to create "collection" buffers from a tab? It can limit the number of open buffers per tab, and it will be easier to switch from one (buffer) to another.

+3


source to share


2 answers


Yes, you can have lists of local window arguments:

$ vim
:arglocal foo bar baz
:tabnew
:arglocal arthur robert charles

      

Now :args

the first tab should display:

[foo] bar baz

      

and on the second tab:

[arthur] robert charles

      



One potential problem with this approach is that you are holding back somehow for the argument-specific commands:

:n[ext]
:prev[ious]  (or :N[ext])
:fir[st]     (or :rew[ind])
:la[st]
:argl[ocal]

      

and commands specific to tabs:

:tabn[ext]                         (or gt)
:tabp[revious]  (or :tabN[ext])    (or gT)
:tabfir[st]     (or :tabr[ewind])
:tabl[ast]

      

which are not as flexible as the more general commands available if you only use the global argument list ( :b <tab>

, looping :bn/:bp

...).

However, you still have the option to search for the plugin on vim.org.

+2


source


I use tabs quite extensively to work with different directories (sometimes 4+ tabs)

By combining a plugin like a CtrlP

team :lcd

, you can effectively have multiple workspaces (each with a different directory) with minimal mental retention.

The command :lcd

only changes the directory for the current window, so the way I use it is as follows.



  • Open a new tab with :tabnew

  • :lcd ~/somewhere/else

  • ctrl + p

    (default binding for CtrlP

    to open files in the current directory) and find the file you want to edit
  • switch between tabs with :tn

    and :tp

    (obviously I have bindings for them since I switch a lot)

This way, basically each tab will have its own working directory and you use ctrl + p

to switch between files / buffers.

+2


source







All Articles