Skip to content

Instantly share code, notes, and snippets.

@MSch
Created July 3, 2011 16:58
Show Gist options
  • Save MSch/1062382 to your computer and use it in GitHub Desktop.
Save MSch/1062382 to your computer and use it in GitHub Desktop.
JavaScript highlighting inside underscore.js templates for vim
" Add this to the bottom of your ~/.vimrc to enable jst highlighting
au BufNewFile,BufRead *.jst set syntax=jst
" Put this file in ~/.vim/syntax/jst.vim
" Vim syntax file
" Language: Underscore.js Templates
" Maintainer: Martin Schuerrer, @MSch <martin@schuerrer.org>
" Version: 2
" Last Change: 2011 Jul 3
" Read the HTML syntax to start with
runtime! syntax/html.vim
unlet b:current_syntax
if exists("b:current_syntax")
finish
endif
syn region jstBlock containedin=ALL start="<%=" keepend end="%>" contains=@htmlJavaScript,htmlCssStyleComment,htmlScriptTag,@htmlPreproc
syn region jstBlock containedin=ALL start="<%" keepend end="%>" contains=@htmlJavaScript,htmlCssStyleComment,htmlScriptTag,@htmlPreproc
let b:current_syntax = "jst"
@jamiel
Copy link

jamiel commented Dec 4, 2012

The exists conditional check is redundant because you've just unset that variable. I don't think you need lines 12 to 16 at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment