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?
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?
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.
:call map(glob('src/Class.*', 0, 1), {_,v -> execute('tabnew '..fnameescape(v))}). You could turn it into a custom:Tabnewcommand::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 '20 at 09:53