Sublime Forum

Run Selection as Ruby Code?

#1

I’ve searched around for this, but have so far come up dry. Is there a way to run the currently selected text through a ruby interpreter and replace with the result?

0 Likes

#2

I see from the Build System documentation [1] that it’s possible to use any executable or shell script to “build” your project or file. I thought this might be a solution, but it doesn’t appear to allow for piping selected text through to the shell. It does allow for the whole file, however:

{
    "cmd": "python", "-u", "$file"],
    "file_regex": "^ ]*File \"(...*?)\", line ([0-9]*)",
    "selector": "source.python"
}

[1] sublimetext.info/docs/en/referen … stems.html

0 Likes

#3

I’m still searching for an answer, but for others who may find this post later:

Darin Morrison has created a python version of what I’m looking for and hosts it at github [1]. I wonder if it would be easy to modify it to execute selected text inside a Ruby interpreter instead…

[1] SublimeMeta - execute python / shell commands from buffer

0 Likes

#4

I’ve done for PHP, you can tailor to your needs.

github.com/ralphschindler/Sublime-PHP-Extras

-ralph

0 Likes