Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Add CoffeeCompile command

  • Loading branch information...
commit 0e8e63fded2be5720d16791846cc87b2b2278efc 1 parent 17b3524
@kchmck authored
Showing with 28 additions and 0 deletions.
  1. +3 −0  ftplugin/coffee.vim
  2. +25 −0
3  ftplugin/coffee.vim
@@ -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> &
@@ -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](
+and shows an output like:
+ ![Compiled](
+Calling `CoffeeCompile` with a range, like in visual mode, compiles the selected
+snippet of CoffeeScript:
+ ![CoffeeCompile Snippet](
+and shows an output like:
+ ![Compiled Snippet](
+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.