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


and set it to

HTML -> Django HTML Template

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.

| improve this answer | |
  • 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 Jan 11 '14 at 22:31
  • @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 Jan 11 '14 at 22:32
  • edited my answer to remove unneeded blathering on my part. – verdammelt Jan 11 '14 at 22:41
  • Evidently I'm not allowed to fix a 1-character typo without more rep: it should be :edit $MYVIMRC, without the first R – Izkata Jan 31 '14 at 17:48
  • 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 Feb 3 '14 at 2:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.