I often find myself wanting to open multiple tabs at the same time from within vim.

I would like something like this:

:tabnew src/Class.*

which would open all matching files in separate tabs. Is there a way to get this functionality?

  • 1
    Try this: :call map(glob('src/Class.*', 0, 1), {_,v -> execute('tabnew '..fnameescape(v))}). You could turn it into a custom :Tabnew command: :com -bar -nargs=1 Tabnew call map(glob(<q-args>, 0, 1), {_,v -> execute('tabnew '..fnameescape(v))}). To use it, you would execute: :Tabnew src/Class.*. See also How can I open multiple tabs at once?.
    – user938271
    Jan 14, 2020 at 9:53

1 Answer 1


To open a bunch of files you can use :h :args and :h :all. That is, to open all Class.* files (and only such files!) in the current tab you can do just args Class.* | all (or args Class.* | tab all to open each file in a new tab).

It requires a bit more work if you want to keep all opened windows/tabs intact and to preserve the global arglist. The target command can be defined like that:

command! -bar -nargs=+ -complete=file Tabedit tabnew | arglocal |
    \ args <args> | silent execute 'argdo tabedit' | tabclose

Now Tabedit Class.* should do the job.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.