Send Text to REPL Using SublimeREPL and Sublime Text 2
Asked Answered
A

2

4

I'm having trouble getting started with SublimeREPL. I have a python program, and can start a python interpreter inside of SublimeText2.

However, I would like to use either the Eval In Repl and Transfer to Repl features, but they don't seem to do anything. How do I associate a repl with my file in sublime text 2 so these will work?

Aksoyn answered 16/10, 2012 at 16:33 Comment(1)
I'm having trouble getting any text for any REPL to evaluate properly as well, whether it's Python or Clojure, on Mac OS X.Siler
U
4

History

To be honest eval for python never worked reliably. It was plagued with strange compilation errors (mainly caused by whitespace/blank lines) and dozens of unnecessary ">>> " prompts showing up during evaluation.

My attempt to fix it using temporary files was only moderately successful and broke down completely with the ability to run remote Pythons over ssh: http://www.youtube.com/watch?v=zodAqBvKQm0

Now

However it seems that I've finally cracked it :) (with a surprisingly short solution that feels hacky but AFAICT should be orders of magnitude more reliable than the previous one, link for the curious: https://github.com/wuub/SublimeREPL/blob/master/text_transfer.py#L43)

Howto

  1. Install SublimeREPL 1.2.0 (released +- 10 minutes ago)
  2. Run Python REPL (any one you wish, w/ or w/o virtualenv)
  3. Focus a file you wish to evaluate
  4. Tools -> SublimeREPL -> Eval in REPL -> File or [Ctrl+, f]
  5. Play with other options (line evaluation should be useful, you only need one cursor in each line you wish to eval, try [Ctrl+Alt+<down-arrow>])
  6. ...
  7. Profit! :)
Urgency answered 16/10, 2012 at 18:43 Comment(2)
I have read a few threads related to this but still can't get it sorted out. I am on OSX Mountain lion and primarily using the Clojure and Ruby REPLs. I might be missing something on the comma commands but when I hold control and comma at the same time then hit b (eval a block in repl) the cursor just moves back one char. I have done as you suggested elsewhere and watched the sublime key log. The log shows "command: move_to {"by": "characters", "forward", "false"}. Hitting f instead of b moves forward and s return "no command for selector: noop:". Thanks for any tips!Gailgaile
@JonRose I'm three years late to the party (sorry!) But I learned that the shortcut works when I press CTRL + , then release both keys, THEN press f.Daumier
F
3

I had the same problem, namely SublimeREPL wouldn't evaluate a file or selected lines. Amazingly this worked:

  1. Remove REPL (Preferences-> Package Control -> Remove package)
  2. Quit and restart Sublime Text
  3. Install REPL (Preferences-> Package Control -> Install package)
  4. Quit and restart Sublime Text

Voila!

Ferree answered 14/6, 2013 at 21:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.