Question

I have a script, which calls in an external program in a foreach loop. This external program opens a vim terminal to add in my comments each time when the loop is iterated. Is there any way I can automate this part? Any pointers would be greatly appreciated.

Was it helpful?

Solution

The question is: Do you have control over the Vim invocation done by the external tool?!

Usually, such programs use an environment variable like $EDITOR to determine the user's preferred editor program. If that is the case (or you can even modify the external tool), you can write a non-interactive editor replacement script that automatically applies whatever changes you want automated. Here's a simple example with sed:

#/bin/sh
sed -i -e 's/foo/bar/' "$@"

If the Vim invocation is hard-coded, you may have to name this script vim, and mess with $PATH to have it picked up by the external tool.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top