I often switch back and forth between multiple files at once in vi and am always adding more with tabe. Is there a way to add more than one tab at the same time while keeping all my open tabs?

I've tried the obvious tabe *.php but apparently tabe only takes one file because that yields a too many arguments error. I've also tried adding the files to args and then opening args with tab all as per this answer but that closes my open tabs (probably because I'm overwriting args). I guess what I'm trying to do is append file names to args. Anyone know how to do that?


4 Answers 4

  1. Add all your *.php files to the argument list:

    :args *.php
  2. Move each item in the argument list to a new tab:

    :argdo tabe

But you should think again about your use of tabs: buffers are a vastly simpler metaphor.

  • 1
    I tried this. It still close my open tab.
    – Yitzchak
    Jan 27, 2014 at 15:03

If you don't want to mess with args define function

fu! OpenTabs( pattern )
    let list = split(expand(a:pattern), '\n')
    call map(list, "'tabe ' . v:val")
    for c in list | exe c | endfor

For instance to edit all your rc files in tabs do:

:call OpenTabs( '.*rc' )

Other then that you could use argadd so your current list is not replaced.


I would echo what @romainl said: you should try getting used to buffers instead (I was in exactly the same position as you were about six months ago, and now I almost never use tabs).

That said:

:tab ball

will open all existing buffers (files that you're editing) in separate tabs. So you could use:

:e *.php
:tab ball

See :h ball and :h tab within vim.

  • 2
    :e and related commands like :tabedit or :split don't take more than one argument, that's why we must populate the arglist first. :ball is cool, though.
    – romainl
    Jan 24, 2014 at 23:12

Using CtrlP plugin you can select multiple files matching a specific search.

After you entered your search use <C-j> and <C-k> (or arrows) to move in the result list and <C-z> to select/unselect a file. Then use <C-t> to open your selection in tabs.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .