Last active
August 29, 2015 14:01
-
-
Save jsborjesson/922904852bb5a470b7aa to your computer and use it in GitHub Desktop.
Execute selected ruby into inline comments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| " Inline ruby interpretation, inspired by RubyTapas. | |
| " | |
| " Example output when run over the top line: | |
| " | |
| " 3.times { |num| puts num } | |
| " # => 0 | |
| " # => 1 | |
| " # => 2 | |
| " | |
| vmap <leader>r :!tee >(cat) \| ruby \| sed 's/^/\\# \=> /'<cr> |
Author
Author
This is basically a poor man's seeing is believing in one line. Obviously much worse but still cool.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Broken down:
teepipes to two commands, the first iscatthat just repeats what it gets to not replace the original coderubyoutputs the result when things are piped to itsedputs the comments in front of the result, with some wonky escaping