11

I'm using vim for LaTeX and I'm using latex-suite. It gives me nice syntax highlighting and folding, but in large files syntax highlighting gets "confused". If I open all folds, the syntax highlighting turns OK. I would like it to "just work" all the time though.

I seem to recall an option that would increase the number of lines that is used as basis for determining syntax highlighting but I cant find it.

svrist
  • 7,042
  • 7
  • 44
  • 67

3 Answers3

16

I don't edit LaTeX, but perhaps you want ":syn sync fromstart"? Just be warned that this can significantly slow down Vim since it forces Vim to do syntax highlighting parsing for the whole file rather than a section of the file. See ::help :syn-sync".

Heptite
  • 457
  • 3
  • 13
12
  • Ctrl+L in normal mode forces a redraw and often fixes syntax colour problems.
  • zRzMzx (i.e., expand all folds, contract all folds, fold to show current line) sometimes fixes syntax highlighting problems related to folds
Jeromy Anglim
  • 33,939
  • 30
  • 115
  • 173
1

10 years later, this is still somehow an issue. Similarly as Jeromy, I suggest pressing zRzMzzza which stands for

  1. open all folds
  2. close all folds
  3. open (toggle) the fold I'm on
  4. center buffer on this line

It looks like we need to learn to live with this

B--rian
  • 5,578
  • 10
  • 38
  • 89