Syntax highlight for .ejs files in vim

What is the best way to make vim highlight ejs (http://embeddedjs.com/) files? Is it possible to set up html highlight for the file in general and javascript highlight to it's parts inside <% %>? Appreciate your help!


Solution 1:

Credits goes to @inkedmn just wanted to point out that html binding works way better, therefore put this in your ~/.vimrc file:

au BufNewFile,BufRead *.ejs set filetype=html

Solution 2:

Here's something I whipped up today (made some modifications to the eruby script). It requires the vim-javascript plugin to be installed.

https://github.com/briancollins/vim-jst

Solution 3:

I've had the best results downloading this syntax file directly into ~/.vim/syntax

Solution 4:

If you want them to be highlighted like regular .js files, you could add this to your .vimrc:

au BufNewFile,BufRead *.ejs set filetype=js

Not 100% sure that's what you're after - hope it helps.