1

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?

Yitzchak
  • 4,474
  • 7
  • 28
  • 44

4 Answers4

1

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
endf

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.

1
  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.

romainl
  • 23,415
0

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.

evilsoup
  • 14,056
0

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.

Yannick
  • 121