VIM - how to open .html files with django html syntax rather than just html syntax?

8

2

I use Django a lot and I just want to open all .html files with the htmldjango syntax rather than html syntax. Is there a way for me to tell vim to open all html files with a htmldjango syntax?

Because at the moment, everytime I open an html file, I have to always click on

Syntax

and set it to

HTML -> Django HTML Template

user216485

Posted 2014-01-11T21:53:00.587

Reputation: 265

Answers

9

To tell VIM to use this style evertytime it loads and HTML file put this into your VIMRC:

au BufNewFile,BufRead *.html set filetype=htmldjango

You can quickly edit your VIMRC file by executing :edit $MYVIMRC.

verdammelt

Posted 2014-01-11T21:53:00.587

Reputation: 369

That menu is the default list of all installed Vim syntax files, and syntax/htmldjango.vim also ships with Vim (version 7.3+) – Ingo Karkat – 2014-01-11T22:31:12.310

@IngoKarkat AH! I didn't find it because i was looking for a file starting with django! Whoops. Glad my answer was still helpful. – verdammelt – 2014-01-11T22:32:09.243

edited my answer to remove unneeded blathering on my part. – verdammelt – 2014-01-11T22:41:02.307

Evidently I'm not allowed to fix a 1-character typo without more rep: it should be :edit $MYVIMRC, without the first R – Izkata – 2014-01-31T17:48:05.877

@Izkata - thanks i fixed it now. I don't think it is a rep thing. If it is not your question/answer you can't do super tiny edits. – verdammelt – 2014-02-02T15:30:28.447

@verdammelt At 2000 rep you can do those small edits without having to wait on the review queue - the "too small edit" limit is in place so that the review queue doesn't get cluttered up with those tiny edits. IMO the limit should be abolished...

– Izkata – 2014-02-02T15:44:19.837

1@Izkata ah, learn a new thing every day I guess. 2000 seems pretty damn high though - not sure I feel strongly enough to abolish it - maybe just change it to $(MY_CURRENT_REP)-1 :) – verdammelt – 2014-02-03T02:12:58.400