Wednesday, June 22, 2011

Syntax highlighting Perl + SQL

Hi all,

I have a bunch of Perl code which has embedded SQL in HEREDOCs. It can look like this:

    my $result = $object->do_something(<<'SQL', $some_var);
    SELECT this
      FROM that
     WHERE bar = ?
    SQL

I'm trying to get the SQL in HEREDOCs highlighted. I've put this in my ftplugin/perl.vim (snarfed from this link http://vim.wikia.com/wiki/VimTip857):

    syntax on                                                                                                                              
    syntax include @SQL syntax/sql.vim
    syntax region sqlSnip matchgroup=Snip start=+<<['"]SQL['"].*;\s*$+ end=+^\s*SQL$+ contains=@SQL
    hi link Snip SpecialComment

However, which the leading and trailing SQL delimiters have the correct highlighting, the SQL is not syntax highlighted. However, if I type the above vim commands in when editing a text file, it seems to work (just not for Perl). How do I debug this?

Cheers,
Ovid

--
Live and work overseas - http://overseas-exile.blogspot.com/
Buy the book           - http://www.oreilly.com/catalog/perlhks/
Tech blog              - http://blogs.perl.org/users/ovid/
Twitter                - http://twitter.com/OvidPerl/

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: