Sublime Forum

Executing selected code (while keeping history)

#1

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?

0 Likes

#2

I’ve put together an example video: https://streamable.com/13fu7

0 Likes

#3

It sounds like you are looking for a “REPL”. Check out https://packagecontrol.io/search/repl for some options. I don’t use one, so I can’t give a recommendation.

0 Likes

#4

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:

0 Likes

#5

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.

0 Likes

#7

you can use Terminus

0 Likes