:vnoremap gff :<C-U>'<,'>g/^/silent! exec "!gnvim " . shellescape('<cfile>') <bar> redraw!<cr>
The mapping is for visual mode, and performs a global on all lines that match /^/
...have a start. Then the rest is the same.
Since exec
is run synchronously you will only get one instance at a time and your current vim instance will block waiting for the first launched gnvim
to end.
To get multiple instances at once you'll need to ether use the OS's background process management ( &
in unix systems), or use some sort of dispatching system like screen
or tmux
. See tpope's Dispatch plugin.
So assuming you are on a Linux/BSD/OSX system
:vnoremap gff :<C-U>'<,'>g/^/silent! exec "!gnvim " . shellescape('<cfile>') . " &" <bar> redraw!<cr>
If you are on Windows you can use START /B program
:vnoremap gff :<C-U>'<,'>g/^/silent! exec "!START /B gnvim " . shellescape('<cfile>') <bar> redraw!<cr>
To script this up using OS detection:
if has("win32") || has("win64")
:vnoremap gff :<C-U>'<,'>g/^/silent! exec "!START /B gnvim " . shellescape('<cfile>') <bar> redraw!<cr>
else
:vnoremap gff :<C-U>'<,'>g/^/silent! exec "!gnvim " . shellescape('<cfile>') . " &" <bar> redraw!<cr>
endif