Parse::RecDescent vim trick

Just thought I’d share this. If you’re using Parse::RecDescent and editing with vim, you’d probably like your grammar to be syntax highlighted (at least I do). Here’s a nice little trick to fool vim (and I don’t consider this a bug; vim folks, don’t fix this!):

    my $grammar = <<'#'EOG';
    grammar goes here

vim doesn’t grok ‘ inside heredoc quoting, so it thinks that the # is the end of the heredoc, and puts normal highlighting back after that.


1 thought on “Parse::RecDescent vim trick

  1. rock! I was looking for exactly that solution… google pointed me at you, and you solved my problem.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s