Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 '14 at 19:45
1  
What does :verbose set syntax? (with the question mark as part of the command) show? – Heptite Apr 29 '14 at 0:52
up vote 3 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 '14 at 11:01
    
So yeah, this file in particular isn't being recognized as a js file. – seyDoggy Apr 29 '14 at 11:02
1  
:set syntax=javascript did the trick. Thanks. – seyDoggy Apr 29 '14 at 11:04
1  
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 '14 at 14:49
1  
Thanks, this happened to me too using vim with spf13. No clue why(I did nothing, even reinstalled vim with spf13 and it happened again), the problem anyway was that filetype was lost for some reason. Fully working now! – Rawa Sep 12 '14 at 18:43

You must log in to answer this question.

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