Sublime Forum

Executing selected code (while keeping history)


I’ve installed the BuildParts plugin that lets me execute highlighted lines code only, however each execution is “separate”.

Lets say I have two lines of code:
myVar = (2 + 2)
print (myVar)

I would like to select the top line, execute the code (initialize the variable myVar with the result of 2+2), and then execute the next line (with the result). The problem is that for each time I execute, it doesn’t care about what I initialized in the previous execution.

I was wonder if there was some way to prevent it from “resetting” all variables for each time I executed? Like working in a continuous session. I like this way of working as I find it easier to play around with and test chunks of code in a larger script (step by step). Is there some way to achieve this in Sublime?



I’ve put together an example video:



It sounds like you are looking for a “REPL”. Check out for some options. I don’t use one, so I can’t give a recommendation.



I couldn’t find anything for ST3 and Python3, but having a term (REPL) for what I’m looking for will hopefully help when looking around for this. Thank you :slight_smile:



There is Sublime REPL, but I don’t know if that will do what you want. You may be wanting an IDE where you can set breakpoints and execute to the breakpoint.
I don’t use Sublime REPL for the purpose you describe, but you can try it and see.



you can use Terminus