So, to begin, this is similar to Pipe shell command into buffer in real-time.
The difference is that the top answer there pipes the output to a new buffer. How do I pipe the output to the editor itself in real time?
For example, I have this open in my vim (with line numbers on for illustration):
1 for num in "a" "b" "c"; do echo "${num}"; sleep 1; done
2
3
4
What I want is to be able to run a command that execute that line (something like yyp!!bash
), and get these in the editor in the interval of 1 second:
1 for num in "a" "b" "c"; do echo "${num}"; sleep 1; done
2 a
3
4
then
1 for num in "a" "b" "c"; do echo "${num}"; sleep 1; done
2 a
3 b
4
then
1 for num in "a" "b" "c"; do echo "${num}"; sleep 1; done
2 a
3 b
4 c
Is this possible to do in vim?
Currently yyp!!bash
will print the output only after the whole command is finished (i.e., only gets the output after three seconds).
Update
If that's not possible (as hinted in the comments), alternatively I would be interested in an editable terminal, essentially being able to edit the output (and the input) of :term
.
:help channel.txt
. Perhaps it is doable.:h :terminal
. Otherwise,r !cmd
would write the output ofcmd
after the command is finished.:term
?