问题
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?
回答1:
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
- Install SublimeREPL 1.2.0 (released +- 10 minutes ago)
- Run Python REPL (any one you wish, w/ or w/o virtualenv)
- Focus a file you wish to evaluate
Tools -> SublimeREPL -> Eval in REPL -> File
or[Ctrl+, f]
- 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>]
) - ...
- Profit! :)
回答2:
I had the same problem, namely SublimeREPL wouldn't evaluate a file or selected lines. Amazingly this worked:
- Remove REPL (Preferences-> Package Control -> Remove package)
- Quit and restart Sublime Text
- Install REPL (Preferences-> Package Control -> Install package)
- Quit and restart Sublime Text
Voila!
来源:https://stackoverflow.com/questions/12919365/send-text-to-repl-using-sublimerepl-and-sublime-text-2