Vim html.erb snippets?? snipMate Need a vim tip

Daniel Upton picture Daniel Upton · Jan 11, 2011 · Viewed 8k times · Source

When I'm in an html.erb file, I get no snipMate snippets.

I would like both HTML and Ruby, or just HTML would be fine, How would I do this?

Would I need to write a set of snippets?

If so, is there a way of pulling in existing snippets without copying them?

Is there a way of telling vim to go into html mode when it sees .html erb?

Answer

Randy Morris picture Randy Morris · Jan 11, 2011

You can use an autocmd to set the filetype to html when opening a ".html.erb" file. This could have unwanted side effects for plugins that work for ".erb" files.

autocmd BufNewFile,BufRead *.html.erb set filetype=html

You can also load more than one set of snippets by using a dotted filetype:

autocmd BufNewFile,BufRead *.html.erb set filetype=html.eruby

See :help snippet-syntax in the snipMate help for more info.