0

Problem: Vim does not highlight all my comments apparently because of folds

alt text http://files.getdropbox.com/u/175564/vim-color-problem.png

Note the line 84 where the comment is not highlighted. I move my cursor up and down the same problem continues.

I am not sure whether it is possible to have a complete syntax highlighting with folds. Google-linux did not give any significant result.

Thanks to Nickd! The commands are highlighted correctly when I unfold all folds before the bug in highlighting at the line 84.

How can you highlight all comments when you use folds in Vim?

HopelessN00b
  • 53,795
  • 33
  • 135
  • 209

3 Answers3

3

vim sometimes gets confused about formatting, especially if you have a very long file. You can sometimes fix it by pressing ctrl-l, but otherwise, you have to live with the bug.

David Pashley
  • 23,497
  • 2
  • 46
  • 73
3

You could try and see if

:syntax sync fromstart

fixes the issue. This forces vim to work from the start of the file each time it does syntax highlighting. This is slow for large files, but may be acceptable on a per file basis. If it works, you could add an autocommand (or ftplugin) to run the above command for the problematic files.

Mark
  • 2,856
  • 20
  • 13
2

I use folds on a daily basis, and never had any problem with comments not being highlighted, or any syntax highlighting problems, for that matter.

But, it depends on filetype. I can't recognize it from the screenshot - what filetype is that ?

Rook
  • 671
  • 6
  • 15