Search code examples
rubysublimetext2sublimerepl

How to use REPL in sublime?


I installed REPL on sublime 2 I'm trying to get a user input by running a sample code such as

puts "hello"
a = gets

for example.

pressing cmd+b just shows me the output but not prompting me for any input. what am I missing?


Solution

  • SublimeREPL does not work through the Build (B) system, but through a separate set of keybindings:

    • Evaluate in REPL:
      • ctrl+,, s Selection
      • ctrl+,, f File
      • ctrl+,, l Lines
      • ctrl+,, b Block
    • Transfer in REPL (just copy, without evaluating it):
      • ctrl+shift+,, s Selection
      • ctrl+shift+,, f File
      • ctrl+shift+,, l Lines
      • ctrl+shift+,, b Block

    Note: ctrl+,, f means: press Ctrl and Comma, release all, press F.

    For transferring/evaluating a file, make sure that it is saved first. If you would like to see the code you transfer before it is evaluated, set "show_transferred_text": true in your SublimeREPL preferences - Sublime Text 2 -> Preferences -> Package Settings -> SublimeREPL -> Settings - User.

    NOTE You need to start your REPL before transferring/evaluating code.