Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
Related: How can I open multiple tabs at once? at Vim SE – kenorb Feb 23 '15 at 15:39
up vote 1 down vote accepted
  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.

share|improve this answer
I tried this. It still close my open tab. – Yitzchak Jan 27 '14 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.

share|improve this answer

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.

share|improve this answer
: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 '14 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.

share|improve this answer

You must log in to answer this question.

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