No more wondering, "How does this compile?"
Last active
August 29, 2015 13:56
-
-
Save lmarburger/9002034 to your computer and use it in GitHub Desktop.
Pipe the selection to the CoffeeScript compile and print the result.
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
function! CompileCoffee() range | |
let code = shellescape(join(getline(a:firstline, a:lastline), "\n")) | |
" shellescape() escapes newlines and encloses in single quotes. Code needs | |
" to be wrapped in double quotes and use real newlines in order to be | |
" processed correctly. | |
let code = substitute(code, "\\\\\n", "\n", "g") | |
echo system("echo " . code . "| coffee -scb") | |
endfunction | |
vmap <leader>c :call CompileCoffee()<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment