Embeds SQL syntax highlighting inside Ruby heredocs labeled SQL
. This will also work to embed other syntaxen, e.g., HTML.
(requires https://github.com/exu/pgsql.vim)
syntax include @SQL syntax/pgsql.vim
Embeds SQL syntax highlighting inside Ruby heredocs labeled SQL
. This will also work to embed other syntaxen, e.g., HTML.
(requires https://github.com/exu/pgsql.vim)
syntax include @SQL syntax/pgsql.vim
" ~/.vim/after/syntax/ruby.vim | |
" Save buffer's current syntax | |
let s:bcs = b:current_syntax | |
unlet b:current_syntax | |
" Magic happens here. | |
syntax include @SQL syntax/sql.vim | |
" Restore buffer's current syntax | |
let b:current_syntax = s:bcs | |
" Match Ruby heredoc format (`<<` or `<<-` start tag, whitespace before end tag) | |
syntax region rubyHereDocSQL matchgroup=Statement start=+<<-\?SQL+ end=+^\s*SQL$+ contains=@SQL |
Wow this works great! Thanks so much! I'm pushing it as a pull request to hashrocket/dotmatrix.