Macvim html5 syntax highlighting in erb templates

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

I installed the latest rails.vim plugin as well as html5.vim and cannot make it work.

Works fine in .html files.

+6
vim ruby-on-rails macvim
source share
3 answers

First of all, just in case, if you are not using it yet, you must install the excellent rails.vim from Tim Pope to work on Rohr with Wim. (Feel free to check out other plugins as well)

Allegedly, the likely reason you don't get html syntax highlighting is because the file is recognized by Vim as [eruby], not [html].

To make sure, open the erb file and type: set filetype?

It will display the file type identified by Vim.

To activate eruby and html5 syntax highlighting at the same time, you can open the erb file and type:
set filetype=eruby.html

I am not sure if multiple file types are 100% supported at the same time.

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

+19
source share

Not sure if this is the same for macvim since I run vim on Linux Mint, but I know that many commands / procedures are the same if they do not match between the two OSs.

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

I used to highlight only pre-html5 tags. With the above fix, it now works with rail syntax, as well as nested html5 tags that were correctly allocated.

As I understand it, the first html syntax definitions are applied first, followed by the html5 definitions. Hope this helps!

0
source share

I think he just did not read that .erb is an HTML file.

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

-one
source share

All Articles