Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add CoffeeCompile command

  • Loading branch information...
commit 0e8e63fded2be5720d16791846cc87b2b2278efc 1 parent 17b3524
Mick Koch authored
Showing with 28 additions and 0 deletions.
  1. +3 −0  ftplugin/coffee.vim
  2. +25 −0 readme.md
3  ftplugin/coffee.vim
View
@@ -13,6 +13,9 @@ setlocal formatoptions-=t formatoptions+=croql
setlocal comments=s:###,m:\ ,e:###,:#
setlocal commentstring=#\ %s
+" Compile some CoffeeScript.
+command! -range=% CoffeeCompile <line1>,<line2>:w !coffee -scb
+
" Compile the current file on write.
if exists("coffee_compile_on_save")
autocmd BufWritePost,FileWritePost *.coffee silent !coffee -c <afile> &
25 readme.md
View
@@ -52,6 +52,31 @@ extension or a `Cakefile` will load everything CoffeeScript.
Everything will then be brought up to date.
+### Compiling a CoffeeScript Snippet
+
+The `CoffeeCompile` command can be used to peek at how the current file or a
+snippet of CoffeeScript would be compiled to JavaScript. Calling `CoffeeCompile`
+without a range compiles the entire file:
+
+ ![CoffeeCompile](http://i.imgur.com/AZAAd.png)
+
+and shows an output like:
+
+ ![Compiled](http://i.imgur.com/5Huj4.png)
+
+Calling `CoffeeCompile` with a range, like in visual mode, compiles the selected
+snippet of CoffeeScript:
+
+ ![CoffeeCompile Snippet](http://i.imgur.com/SKqCc.png)
+
+and shows an output like:
+
+ ![Compiled Snippet](http://i.imgur.com/wkO4f.png)
+
+The command can also be mapped to a visual mode key for convenience:
+
+ vmap KEY :CoffeeCompile<CR>
+
### Customizing
#### Compile the current file on write/save
Please sign in to comment.
Something went wrong with that request. Please try again.