Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
Pardon? Please elaborate. – Majenko Apr 15 '11 at 9:15
rewrote question. – noxoc Apr 15 '11 at 9:45

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:

(echo '<?php'; cat - ) | env php
share|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? – noxoc 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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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