1

I was toying around with my .vimrc editing it, and then checking in another file whether my changes worked or not.

But now I ended up in a state where opening one file with vim file1.tex (this was the one I used for testing) doesn't load syntax highlighting and using vim file2.tex loads the syntax highlighting.

My thought was that maybe I accidentally set something specific for file1.tex which persists, but the only info I found was .viminfo and deleting that did not help.

  • 1
    Welcome to this site! Have you tried How do I debug my vimrc? Maybe that will allow you to find out the offending configuration. – statox Oct 31 '19 at 10:29
  • It is definitely NOT my .vimrc, because if I make a copy of said file and open it in vim it works as expected, so it is something that happens to just one specific file and not even related to the contents of the file. – fbence Oct 31 '19 at 10:37
  • 3
    An :autocmd that matches the filename from your .vimrc could very well be the reason. Try with a minimal .vimrc (that only enables filetype detection and syntax highlighting). I would guess that the problem is gone then. If it isn't, you have to dig deeper; I would open the file from within Vim with :20verbose edit file1.tex and check the logs. – Ingo Karkat Oct 31 '19 at 12:10
  • 2
    Yes, autocmd patterns can match full / partial paths in addition to the more common filenames. Instead of going through the captured logs, you can also just look at the :autocmd output itself. The event probably is BufRead. – Ingo Karkat Oct 31 '19 at 12:28
  • 2
    Also check :set ft? on the problem file, to make sure the file type is being set correctly (compare it to other files or a copy of this file on a path that works...) – filbranden Oct 31 '19 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.