开发者

macvim html5 syntax highlighting in erb templates

I am trying to get syntax highlighting for HTML 5 elements in erb templates working.

I have installed newest rails.vim开发者_JAVA技巧 plugin as well as html5.vim and can't seem to get it to work.

Works fine on .html files.


First of all, just in case you are not already using it, you should install the excellent rails.vim from Tim Pope to work on Ror with Vim. (Do not hesitate to check his other plugins as well)

That being said the likely reason why you don't get the html syntax highlighting is because the file is recognized by Vim as [eruby] and not [html].

To be sure, open an erb file and type: set filetype?

It will display the type of the file as identified by Vim.

To get both eruby and html5 syntax highlighting working at once, you can open an erb file andtype:
set filetype=eruby.html

I am not sure that multiple filetypes at once are 100% supported though.

If it works, you can add the following line to your .vimrc so that the filetype html is automatically added every time you are opening an *.erb file: autocmd BufRead,BufNewFile *.erb set filetype=eruby.html


Not sure if this is the same for macvim, as I am running vim on Linux Mint, but I do know that many commands/procedures are the same if not similar between the two OSes.

I was digging into this same issue for the last hour or so. I was able to fix it by downloading html5.vim from https://gist.github.com/256840 and saving it as ~/.vim/after/syntax/html.vim

Previously, I was only getting pre-html5 tags highlighted. With the above fix, it is now working with the rails syntax as well as the interspersed html5 specific tags both being properly highlighted.

It is my understanding that the original html syntax definitions get applied first, followed by the html5 definitions. Hope that helps!


i think its just that it doesn't read that .erb is a HTML file.

BTW @Pasta, vim is really good for productivity if you know how to use it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜