Sublime Repl for Sublime text: stay on the same tab when you run it

A problem with Sublime text can be that if you run Sublime repl to run a python script it goes into the console of the interpreter, but loses the focus on the tab, if there are others on the right of the tab of the script you launched. This is very frustating, because you got to go back to the previous one and if you got a lot of tab opened you may even not see immediately where the script is. I found this solution in a forum, so I want to share it with you.

Binding Sublime Repl to ctrl+b

[


{"keys": ["ctrl+b"], "command": "repl_open",
 "caption": "SublimeRepl",
 "id": "SublimeRepl",
 "mnemonic": "R",
 "args": {
    "type": "subprocess",
    "encoding": "utf8",
    "cmd": ["C:/Users/giova/AppData/Local/Programs/Python/Python39/python.exe",
        "-u",
        "-i",
        "$file_basename",
    ],
    "cwd": "$file_path",
    "syntax": "Packages/Python/Python.tmLanguage",
    "external_id": "python",
    "extend_env": {"PYTHONIOENCODING": "utf-8"}
        }},

Go in Main.sublime-menu

Follow this path and go in SublimeREPL\config\Python\Main.sublime-menu, right before the “external_id”: “python” argument add this:
"view_id": "*REPL* [python]"

"view_id": "*REPL* [python]"

Go in the sublimerepl.py

Now go in SublimeREPL\sublimerepl.py.
and then to change the line:

if view.id() == view_id

into:
if view.name() == view_id

I get the answer from here https://github.com/wuub/sublimerepl/issues/481 by ggstefanov.

A terminal in Sublime text

Terminus, a terminal il Sublime text

Terminus


Subscribe to the newsletter for updates
Tkinter templates
Avatar My youtube channel

Twitter: @pythonprogrammi - python_pygame

Videos

Speech recognition game

Pygame's Platform Game

Other Pygame's posts

Published by pythonprogramming

Started with basic on the spectrum, loved javascript in the 90ies and python in the 2000, now I am back with python, still making some javascript stuff when needed.