Search code examples
sublimetext3sublimerepl

How to run selected Python codes using SublimeREPL


I have set up the sublimeREPL and can run a .py file using Command + B with no problem. However, I was wondering how to run selected lines of codes only instead of the whole file.

On https://github.com/wuub/SublimeREPL, it says that SublimeREPL supports "Quickly run selected script." But how to do it? Thank you!


Solution

  • Install SublimeREPL following guide on their GitHub repository.

    Create or open your python script. Then, using Command Palette, type SublimeREPL: Python and select it. It should open a Python REPL.

    They listed shortcuts for running parts of python file at their documentation, but I'll also list them here:

    • ctrl+,, s -> Evaluate in REPL selection
    • ctrl+,, f -> Evaluate in REPL file
    • ctrl+,, l(L) -> Evaluate in REPL line
    • ctrl+,, b -> Evaluate in REPL block of code

    Note: ctrl+,, s means:

    1. press Ctrl and Comma
    2. release all
    3. press s.

    In the example below, I ran 3 print statements by selecting them and by pressing ctrl+,, s shortcut:

    Sublime REPL run lines