This has been discussed in several questions on SO, and the unofficial docs are currently being updated to more clearly state this: neither ST2 nor ST3 supports direct input to programs running within build systems inside Sublime Text: C/C++'s scanf
and colleagues do not work, nor do Python's raw_input
(Python 2) or input
(Python 3), Ruby's gets
, Java's Scanner
class, etc. This is a fundamental limitation of the program.
However, it can be worked around in two ways. First, you can run your build system in a terminal. Second, if you are using an interpreted language like JavaScript, Python, Ruby, Perl, Scheme and all the associated Lisp-like languages like Clojure, Erlang, Haskell, PHP, R, etc., you can check out the excellent SublimeREPL
plugin. You can open a REPL for interactive programming, and send programs (or bits of them) to it and interact with them just as on the command line. Documentation is here.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…