Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have files containing code within a prefix-based structure, such as:

perl: sub abc {
perl:     return "def";
perl: }

I'd like to be able to highlight the perl as normal. i.e. ignore the perl: prefix. Using the built-in help for syntax I have:

syntax include @Perl syntax/perl.vim
syntax region testPerl start=/^perl: \?/ end=/$/ contains=testPerlContinue,@Perl
syntax match testPerlContinue "\$perl:" contained

However, as expected, this treats the perl: prefix as part of the code; an obvious example of this breaking is where a Perl 'quote' carries over several lines.

Is it possible to ignore prefixes within Vim when syntax highlighting?

share|improve this question
    
It is very unlikely this will be easy, if it's even possible. For example, if you look at the perl.vim syntax file you'll find at least a few patterns that "anchor" to the beginning of the line. –  Heptite Jan 10 '12 at 17:32
    
Thanks for pointing out the anchoring problem. It certainly indicates it's not possible. The alternative is to pre-process the file into regions more conducive to syntax highlighting, then post-process it back to the original format. I'd ideally like to avoid that for the 'simple' task of editing a file though. –  Unk Jan 11 '12 at 10:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.