Created
June 22, 2011 15:01
-
-
Save rwstauner/1040278 to your computer and use it in GitHub Desktop.
highlight SQL syntax in a Perl heredoc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" ~/.vim/after/syntax/perl.vim | |
let s:bcs = b:current_syntax | |
unlet b:current_syntax | |
syntax include @SQL syntax/sql.vim | |
let b:current_syntax = s:bcs | |
" match optional, surrounding single or double quote and any whitespace in the heredoc name | |
syntax region perlHereDocSQL matchgroup=Statement start=+<<\(['"]\?\)\z(\s*SQL\s*\)\1+ end=+^\z1$+ contains=@SQL |
Perl 5 heredocs can't have leading whitespace before the terminator, so it should be
end=+^SQL$+
Right, any whitespace would have to be included in the "start" match, and be matched exactly in the "end".
I was attempting to apply something else i had used to Ovid's (very simple, very specific) heredoc example.
I edited the whole thing to make it a bit more versatile. Surely still not 100% but maybe covers a few more cases now.
Anyway, thanks. Always better to be more correct. :-)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If your here doc isn't highlighting it may be that the sql syntax file isn't being processed (because the b:current_syntax is already set to something else). Turning it off works for me: