Vim syntax highlighting lost on single file

colorshighlightingsyntaxvim

I have a strange thing happening on a single file. When I open the file under it's original name, the highlighting is lost (":syntax on" does nothing). But if I cp that file with another name and open it, the syntax highlighting returns. If I mv that copy back to the original file name, the highlighting is gone again.

I can't show you images (as my rep is not high enough), but I assure you if I could, you could clearly see that file a.js has no highlighting while a_copy.js does.

Best Answer

You provide very little information about your environment and configuration, so I can just help you help yourself.

Compare the following options for the two different JavaScript files:

:verbose setlocal syntax? filetype?

Then check the list of :autocmd for any pattern that might target the problematic JavaScript file. Do you use a local vimrc plugin? It might affect this, too.

If all that doesn't provide a clue, capture the sequence of commands with

:set verbose=20 | edit a.js

and watch out for commands that affect 'syntax'.