It all starts from a shell. For example I am using urxvt with zsh. There I open some file with gvim. In this case it is a LaTeX file. Now I need to execute some command (for compiling the document, e.g.pdflatex).
How can I have the original shell, from where gvim was started, execute that command?
It would also be acceptable if gvim had to open a new shell once and after that execute every future call of the designated command (pdflatex) in that shell, while I can still type in it manually.
The problem with running :!pdflatex directly is, that the output is shown, but if it has gotten too long scrolling is not possible and after I press return, it is all gone.
The idea with using a shell means, that the window focus does not have to switch over by default. So in general the output of my command is visible, but unless an error occurs I can just keep on working in gvim. Now if a new shell was spawned everytime I run the command, this kind of workflow would certainly not be possible.
GVIM does not retain a “handle” to the shell that launched it in a way that allows it to send commands back to it. Because of they synchronous execution, you also cannot launch a shell from GVIM, keep feeding it commands while also continue working in GVIM.
I’m afraid you have to use the functionality of your window manager to launch (and then later re-activate) a shell window, and send the commands as keystrokes to it. On Windows, this can be done (e.g. in VBScript) via
WshShell‘sRun(),AppActivate()andSendKeys()methods; there are probably similar mechanisms for window control on Linux, too.If you don’t mind having that shell inside your GVIM (emulated, with all its drawbacks), though, there are plugins that enable that.