Make vim play nice with HTML templates inside script tags
Put the following code in ~/.vim/after/syntax/html.vim
. You may have to create the syntax
directory.
unlet b:current_syntax
syn include @HTML $VIMRUNTIME/syntax/html.vim
syn region htmlTemplate start=+<script [^>]*type *=[^>]*text/template[^>]*>+
\ end=+</script>+me=s-1 keepend
\ contains=@HTML,htmlScriptTag,@htmlPreproc
This works only with script tags with type="text/template" attribute, and won't syntax highlight whatever templating language you're using inside. With something like Handlebars you might want to look elsewhere, I simply wanted to make HTML look decent in my templates.
Written by Raine Virta
Related protips
1 Response
Thanks! Thats great!
The only thing I am missing is auto indentation.
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Vim
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#