30

I have gvim 7.2, it recognizes .d files and highlights it correctly according to the syntax of the D programming language. However, .di files are not recognized as D files, and no highlighting is present.

How do I let vim highlight .di files according to D language?

hasen
  • 161,647
  • 65
  • 194
  • 231

2 Answers2

48

This ought to do it in .vimrc:

au BufNewFile,BufRead *.di setlocal ft=d

There are probably other ways, too.

derobert
  • 49,731
  • 15
  • 94
  • 124
  • 6
    If you like to keep your .vimrc relatively clean, you could alternately put this in .vim/ftdetect/d.vim – rampion May 30 '09 at 12:49
  • 1
    If some of your other files are D sources (but don't have name extensions that suggest it), you can add a comment containing a vim modeline like: // vim:ft=d – greyfade Jun 12 '09 at 00:10
2

http://vimdoc.sourceforge.net/htmldoc/filetype.html has the (gritty) detail on filetypes. You can modify the associated plugins by editing your vimrc. look for the rule *.d, and copy/paste that line changing it to *.di

I've not used gvim, so there may be an easier way I'm unaware of

Jonathan Fingland
  • 56,385
  • 11
  • 85
  • 79