Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
1  
You can upload the screenshot on some image sharing site and add the link. –  romainl Apr 28 at 19:45
    
What does :verbose set syntax? (with the question mark as part of the command) show? –  Heptite Apr 29 at 0:52

1 Answer 1

up vote 2 down vote accepted

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'.

share|improve this answer
    
syntax= Last set from /usr/local/Cellar/macvim/HEAD/MacVim.app/Contents/Resources/vim/runtime/syntax/s‌​yntax.vim filetype= Last set from ~/.vimviews/~=+github=+ctc_services-wrapper=+routes=+ctc_inventory.js= –  seyDoggy Apr 29 at 11:01
    
So yeah, this file in particular isn't being recognized as a js file. –  seyDoggy Apr 29 at 11:02
    
:set syntax=javascript did the trick. Thanks. –  seyDoggy Apr 29 at 11:04
    
Still strange; you should have a default detection au BufNewFile,BufRead *.js,*.javascript,*.es,*.jsx,*.json setf javascript that should cover a.js. The .vimviews looks somewhat suspect to me. If you can live with a workaround, a modeline inside the file would probably fix this, too. –  Ingo Karkat Apr 29 at 11:15
    
It was a sudden loss. The syntax was there and then it wasn't. So in all likelihood I had inadvertently hit the right key combo to turn the settings off on that file alone. –  seyDoggy Apr 29 at 14:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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