Skip to content

Instantly share code, notes, and snippets.

@joyrexus
Last active December 14, 2015 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joyrexus/5112582 to your computer and use it in GitHub Desktop.
Save joyrexus/5112582 to your computer and use it in GitHub Desktop.
Vim utils for litcoffee. (Provisional tweaks and supplements for https://github.com/mintplant/vim-literate-coffeescript)
" Add this to ~/.vim/ftdetect/md-litcoffee.vim
" Language: Literate CoffeeScript
autocmd BufNewFile,BufRead *.litcoffee set filetype=litcoffee
autocmd BufNewFile,BufRead *.coffee.md set filetype=litcoffee
" Add this to ~/.vim/ftplugin/litcoffee.vim
" Language: Literate CoffeeScript
ab bang! #!/usr/bin/env coffee
" ,r run/execute code in file (faster to type than ,x)
" ,j show resulting javascript
" ,m show resulting markup
" ,v view file as rendered markdown in a browser
nmap <LocalLeader>r :!coffee %<CR>
nmap <LocalLeader>j :!coffee -p %<CR>
nmap <LocalLeader>m :!marked %<CR>
nmap <LocalLeader>v :!marko % \| browser<CR>
" :<RANGE>R run/execute specified line range
" :<RANGE>J show resulting javascript of specified line range
" :<RANGE>M show resulting markup of specified line range
" :<RANGE>V view specified line range as rendered markdown in a browser
command! -range=% -bar R <line1>,<line2>:w !coffee -s
command! -range=% -bar J <line1>,<line2>:w !coffee -sp
command! -range=% -bar M <line1>,<line2>:w !marked
command! -range=% -bar V <line1>,<line2>:w !marked | browser
if exists("b:did_ftplugin")
finish
endif
let b:did_ftplugin = 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment