Executing Snippets
Here’s a cool way to execute a selection of code from Vim.
- Select the code
- Write the selection to Node.
- Congratulate yourself on being amazing.
Still Here?
OK, I will elaborate.
Select the code with visual mode. You can then write the selection, passing it to Node. This is in the manpage, but no one except the gnarliest of neckbeards would be expected to find it.
:[range]w[rite] [++opt] !{cmd}
Execute {cmd} with [range] lines as standard input
(note the space in front of the '!'). {cmd} is
executed like with ":!{cmd}", any '!' is replaced with
the previous command |:!|.
You can and certainly should read this beautiful answer on StackOverflow
about it. It explains all of it in very friendly terms. Then you can add it to
your .vimrc
and be a super stud. Watch out for all the babes that will
inevitably swarm you and distract you from your man pages.