Sublime Forum

Command Line and Support for Input (default)

#1

Hello,

as a newbie programmer I most frequently have to use console I/O. But Sublime Text does not support that by default. I have looked and haven’t found a package for what I wanted.
So my idea would be that ST when executing a program by hitting cmd+B opens the popup below as usually but in addition to that has a command line and the capabilities to execute e.g. input() in Python. I love ST because it is beautiful, handy and has syntax highlighting etc. without being as complicated as an IDE! I really like that but I always have to write my program, save it, open it up in IDLE where it is executed much slower than ST does.

Who’s thinking the same? :smile:

Regards

Steve

0 Likes

#2

I think it’s currently possible to have cmd+B open an external program (e.g., Terminal) via a custom Build System:

http://sublime-text-unofficial-documentation.readthedocs.org/en/latest/reference/build_systems.html

EDIT:

While this may not be exactly what you’re after, here’s what I meant above:

  1. Create a RunPython.sh script (save it to Packages/User):
#!/bin/sh
osascript -e '
    on run parameters
        tell application "Terminal"
            activate
            try
                do script with command "python " & parameters in window 1
            on error
                do script with command "python " & parameters
            end try
        end tell
    end run
' $@
  1. Create a Build System which calls RunPython.sh:
{
    "shell_cmd": "sh \"$packages/User/RunPython.sh\" \"$file\"",
    "file_regex": "^ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python"
}

A sample of its usage can be seen here.

Also have you seen SublimeREPL?

0 Likes