Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


vsplit of .js source and autocompile on keystroke #39

TomasM opened this Issue · 5 comments

3 participants

TomasM Mick Koch Karl Guertin


Tell me if this is a good idea:

I really like how you can try coffee on the fly on the coffeescript website, where coffeescript is compiled to js on every keystroke. I would like that in vim as well. You wouldn't have to wait to compile the source just to see that there is a syntax error.

Is this possible at all with vim?


Mick Koch

I think it would be possible with a InsertLeave autocmd, which would fire every time you hit escape in insert mode. To get an idea, you can do something similar now by running

:au InsertLeave <buffer> CoffeeCompile | wincmd w

in a coffee buffer.

I guess the differences from this would be a vertical split and smarter buffer handling?

edit: afaict, the only event that fires on each keystroke is InsertCharPre, but it fires before the character is added to the buffer and seems to be more for changing input

Mick Koch

BIKESHEDDING: I needs a command name: CoffeeSplit, CoffeeView, CoffeePlay, CoffeePreview, other?

Karl Guertin

CoffeePreview +1

I'd rather see it stay on InsertLeave. The per-keystroke compiling works for short snippets but not so well for larger files. I'm on a relatively low end machine (2010 MBAir) and I start getting distracting delays in the 50-100 line range for the in-page preview.

Mick Koch

Well now after getting into the code, the commands would be so similar that I'm just going to make "watch mode" and vertical splitting arguments of CoffeeCompile, Then you can use it like:

CoffeeCompile watch vert

This should be on a branch soon to play around with. I'll definitely stick with InsertLeave. The only bad thing is that changing the text outside of insert mode doesn't fire that event.

edit: it's up on the feat-39 branch.

Mick Koch kchmck referenced this issue from a commit
Mick Koch Add watch and vertical modes to CoffeeCompile (#39)
Watch mode emulates the live preview on the coffee homepage. Use it like:

  :CoffeeCompile watch vert
Mick Koch

This is up on master now. Give it a try. Thanks for this idea!

Mick Koch kchmck closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.