I have a quick question about programming using Vim. I sometimes make a silly mistake in my program.
For example, the Python code below has an infinite loop (say foo.py . . . be careful when executing it!)
x = 1
while x == 1:
x = 1
You won’t see any result, but find a fan inside your computer is becoming louder, and you need to stop executing this Python program. On a Unix shell, you can do it by pressing Ctrl-z. Or, on Emacs shell-mode, just pressing Ctrl-c Ctrl-z.
I know how to switch to shell-mode in Vim: :sh (then type python foo.py) or :!python foo.py. But I don’t know how to stop a job on a shell from Vim without killing Vim itself. Does anyone know this?
Why can’t you use <C-C>? By default, it sends an INTerrupt signal unless program is able to catch <C-C>. Vim handles <C-C> like any other <C-...> key, but python does not do this by default.
By the way, <C-Z> in unix shells suspends program while in the case mentioned above you need to kill it which is done using <C-C>. Suspend=pause executing (though most programs are not able to/do not need to handle SIGTSTP/SIGCONT properly).