I'm trying to write a function to open a split terminal in Vim and then run the current file in that terminal. A non-working example trying to explain what I'm trying to do is
function! Foo() :bel term % endfunction
This just opens up the terminal. I tried with another command,
dir, and it seems it's fails because
dir is not a Vim command, so it's still trying to run things in Vim rather than the terminal. I also tried putting the command on the same line e.g.
:bel term % but I get an error:
Error detected while processing function Foo: line 2: CreateProcess failed
And the terminal doesn't even open.
I also tried
function! Foo() :bel term !dir endfunction
though that had the expected result of essentially running
!dir and then returning me to a split window with nothing in the terminal there.
I've also tried to use the
feedkeys() function but I can't find a way to automatically pass the file name in.
How could I achieve this? If it's relevant I'm running Vim on Windows through cmd.