is there a way to send a visual selection (or a range) to an intepreter like php, ruby or node? So that I can easily test small snippets of code.

Alternatively, I have :Sscratch installed. It would be nice if i could execute the code inside of a scratch-buffer. I don't know which one suits my workflow best yet so being able to use both approaches would be nice.

link|improve this question

60% accept rate
Pardon? Please elaborate. – Majenko Apr 15 '11 at 9:15
rewrote question. – Nils Riedemann Apr 15 '11 at 9:45
feedback

1 Answer

Select your code, hit bang (!) and type the name of a program you want your code piped to. For shell code, you can give the name of a shell. For interpreted code you might need to write a wrapper to include tags or headers before sending it to the interpreter.

Edit: Example for php:

#!/bin/zsh
(echo '<?php'; cat - ) | env php
link|improve this answer
yup. In fact I already tried this but this doesn't help me that much. Do you know any existing wrappers? Or where to find sources how to write one myself? – Nils Riedemann Apr 15 '11 at 14:07
These generally don't exist because executing code snippets out of context of their programs is generally not useful to people. Also it would be highly language and environment specific. However it should take like 3 lines of shell script to make it work for basic scenarios. – Caleb Apr 15 '11 at 14:15
See edited answer for a sample wrapper script that accepts standard in and executes it as a php code snippet. – Caleb Apr 15 '11 at 14:26
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.