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
    #'EOG

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.

About these ads

One 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.

    Thanks!

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s