My .vimrc file is as follows:

filetype plugin indent on
syntax on               " enables syntax, e.g. text colour
set number              " show line numbers

The command I use to open files is vim filename. Despite this when I open some files I get all the nice fancy colours in my files whereas I have some files that I can't get the colours to work at all. For example, when I'm editing my .vimrc file the syntax works. When I'm editing another file (called filename.usr - it's just a text file) the syntax doesn't work.

Do you know why this is the case and how I can get the syntax to work correctly for all my files?

  • 2
    What "syntax" do you expect a file named filename.usr to have? What words mean something special depends on what the file is used for -- it's not going to highlight any arbitrary file. Nov 7, 2017 at 16:31
  • Ah okay, I understand, thank you. How would I go about, then, giving the .usr file the characteristics to highlight different expressions? Or to give it those of another file type? Nov 7, 2017 at 16:34
  • The syntax definition files which may be installed somewhere under share/vim/vim*/syntax/* may be of interest. I guess for a unknown file type one could go all Jackson Pollack and spray colors everywhere?
    – thrig
    Nov 7, 2017 at 16:38

1 Answer 1


If you want to treat files ending in .usr like some other type of file (e.g., like a vimrc file), then you can add this to your ~/.vimrc:

autocmd BufNewFile,BufRead *.usr setlocal filetype=vim

Then, when you open files ending in .usr, vim will apply the given filetype's syntax highlighting.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .