Reputation: 1816
I know I can run my code in vim using an external program, but I want that program to stay up and receive my code each time - as opposed to re-running the external program every time.
For example: I edit my Matlab file in vim, and I want to run it. But, I want the matlab instance to be in the background and that vim will use the same instance to keep running my files when I want, instead of opening an new matlab each time.
Is that possible? Thanks.
Upvotes: 2
Views: 483
Reputation: 938
I mainly had this problem for matlab as well. What I did is a mapping that: - copies the edited file name (or part of it) to a temporary clipboard - uses wmcrtl to switch to matlab Then I'm into matlab, so I just type "Ctrl-V" and the scripts runs. It is possible to then automatically go back to vim. See examples here: Vim and matlab GUI - Emulate matlab Run (<F5>) with Vim
Upvotes: 1
Reputation: 172600
When you can configure the external program (or maybe add a wrapper around it) to automatically re-run the file whenever it is modified (in Vim by saving it, or from anywhere else), there's nothing to actually trigger from Vim (except maybe the initial program launch). This is the ideal situation.
In all other cases, you need a notification mechanism from Vim to the external program. Whether this is possible and how it is performed depends on the external program, but usually this is difficult. There are some plugins that e.g. reload an HTML page in the browser whenever it is saved, but I'm afraid there cannot be a generic solution. It's best to re-think your entire approach, then.
Upvotes: 5