I have a number of files with a syntax almost identical to C, though the files have suffixes such as .t, .sc

I would like to have the same syntax highlighting that I have for standard C files ending with the suffix .c.

For any one file I know I can execute:

:set filetype=c

but it is cumbersome to have to execute that command every time.

Is there something I can add to my .vimrc file so that some files with specific suffixes can have "C" syntax highlighting?


2 Answers 2


Yes, you can add the following:

augroup filetypedetect
    au! BufRead,BufNewFile *.t, *.sc setfiletype c
augroup END

However, to help keep your .vimrc tidy, you could also put that in a separate file called filetypes.vim in your .vim directory.


You can put this in your ~/.vimrc, or in a file in ~/.vim/ftdetect:

au BufNewFile,BufRead *.t,*.sc set filetype=c

Also see:

:help new-filetype

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