When searching for a command to enable me to open multiple tabs in normal mode, I found a custom command to do this:
" Open multiple tabs at once
fun! OpenMultipleTabs(pattern_list)
for p in a:pattern_list
for c in glob(l:p, 0, 1)
execute 'tabedit ' . l:c
endfor
endfor
endfun
command! -bar -bang -nargs=+ -complete=file Tabedit call OpenMultipleTabs([<f-args>])
" less typing:
map <C-n> :Multitab
However, this doesn't work when trying to open a path that doesn't exist yet. So one cannot use this to create new files. Example:
:Tabedit *.c
" works: opens all matching .c files
:!touch existing-file.txt
:Tabedit existing-file.txt
" works: opens the existing file
:Tabedit new-file.txt
" doesn't do anything at all
So what I want is for strings that don't require expansion, to open the same as with :tabedit.
*.cand there are no C files...i.e. try to open single file*.c? Might be better to test the pattern for wildcards. If none, open using name as is otherwise useglob(). Question is whether there's a portable, robust way to test for wildcards. (You could simply look for for*,?,**but what about escaped wildcards? Or system specific wildcards?) – B Layer Mar 30 '20 at 22:49*.cas a file name. This is likely not intended, but I can live with it. And as you say, you'd need to have a portable way to test for wildcards, which I'm not keen on jury rigging myself. – bitmask Mar 30 '20 at 23:01. If you don't use[abc]wildcards then you just need[^\\](?|)` and that'll work on Windows, too. Your vim, your decision, though. – B Layer Mar 31 '20 at 00:08