4

I made a syntax file with among others a comment region.

It should work like the "c" syntax. Starting with /* and ending with */.

Syntax:

if exists("dbquery_fold")
    syn region dbqueryComment start="/\*" end="\*/" contains=... extend fold
else
    syn region dbqueryComment start="/\*" end="\*/" contains=... extend
endif

On the whole it works. If I scroll down, either with j or with Ctrlf the whole comment is colorized correct. On :let dbquery_fold=1 I can fold it.

Problems:

I have a very long comment e.g. at the end of a file.

  1. I press G to go to end of file.
    => The comment is not Identified. The text is colored with normal syntax colors.
  2. If I scroll to the end Ctrlf and then back, no matter how
    => Not all lines are colored as comment. At first all lines are correct and then one line is colored and 6 not. Or 3 are colored and some not.

How can I tell vim to show it all as comment?

The file looks like:

Line 1  
...  
Line 120  
/*  
Line 122  
...  
Line 922  
*/
2
  • 3
    :syn sync ccomment should probably fix it, otherwise :syn sync fromstart; see :help syn-sync. There's some more subtleties involved that should be in a good (full) answer though. Aug 22, 2022 at 13:21
  • 1
    @MartinTournoij - syn sync fromstart and syn sync fromstart works! And it seems fast enough. I think you should set your comment as answere. Thanks!
    – Andy A.
    Aug 22, 2022 at 14:45

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.