Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop Sublime Text from executing infinite loop

When I do something like

while True:
    print('loop')

and execute that code in sublime I am not able to stop it. I have to manually kill the process and restart sublime.

Is there a way of setting some kind of 'max_execution_time' or any other workaround which allow us to stop this nicely?

like image 892
Finn Avatar asked Feb 08 '15 18:02

Finn


Video Answer


2 Answers

You want to use Ctrl+Break. For your own information, just go check under Tools in Sublime Text and you'll see Cancel Build and the above hotkey. It'll work just fine for infinite loops. Suffice to say, I've had the same happen! ;)


For Windows users, there is no Break key, so go into Preferences>Key Bindings and change the line

{ "keys": ["ctrl+break"], "command": "cancel_build" }

to a different shortcut, such as Ctrl+Alt+B

like image 106
Eithos Avatar answered Oct 24 '22 07:10

Eithos


For me (on Linux), there is no break key on the keyboard and this shortcut was somehow bound to a different combination: ctrl+alt+c.

You can find where it is bound in the Tools menu:

enter image description here

After interrupting your script you should see the text [Cancelled] printed to the sublimetext console.

like image 9
wim Avatar answered Oct 24 '22 07:10

wim