I am using Vim terminal (:term
) to print the output of my Python scripts in a separate window:
:term python3 myfile.py
And it works, but when I'm trying to redirect input from a file:
:term python3 myfile.py < input.txt
it doesn't do it and just sits there waiting for input.
How do I redirect input in Vim command mode using :term
?
CodePudding user response:
You want to preform shell redirection, but Vim command-line is no shell, so by default whole input is passed as command and its arguments.
If you want Vim to pass the command to shell (e.g. Bash) first instead of executing it directly, you need to use shell
option, like so:
:term shell python3 myfile.py < input.txt
To learn more about Vim build-in terminal options check out :h :term
and :h term open