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?

4
  • What's your fold method?
    – nickd
    Jul 7, 2009 at 19:30
  • @nickd: I use the foldmethod marker. Jul 8, 2009 at 14:06
  • 2
    @Masi: Are the comments highlighted correctly when unfolded?
    – nickd
    Jul 8, 2009 at 21:10
  • @nickd: The commands are highlighted correctly when unfold all folds before the bug in highlighting. Jul 9, 2009 at 15:46

3 Answers 3

3
+100

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.

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.

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 ?

3
  • @Idigas: The file is ~/.zshrc, so it does not seem to have a filetype. Jul 2, 2009 at 17:52
  • 1
    @Masi - every file has a filetype. What does it says for ":echo(&ft)"
    – Rook
    Jul 2, 2009 at 18:09
  • @Idigas: Your command gives me zsh. Jul 3, 2009 at 23:34

You must log in to answer this question.

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