Skip to content

Instantly share code, notes, and snippets.

@reinh
Last active February 20, 2016 00:39
Show Gist options
  • Select an option

  • Save reinh/5448512 to your computer and use it in GitHub Desktop.

Select an option

Save reinh/5448512 to your computer and use it in GitHub Desktop.

Syntax highlight SQL inside <<-SQL heredocs

Similar principle will work to embed other syntaxen, e.g., HTML.

Optional: requires https://github.com/exu/pgsql.vim

    syntax include @SQL syntax/pgsql.vim
" ~/.vim/after/syntax/ruby.vim
let s:bcs = b:current_syntax
unlet b:current_syntax
syntax include @SQL syntax/sql.vim
let b:current_syntax = s:bcs
syntax region rubyHereDocSQL matchgroup=Statement start=+<<-\?SQL+ end=+^\s*SQL$+ contains=@SQL
@dkarter
Copy link

dkarter commented Feb 20, 2016

Wow this works great! Thanks so much! I'm pushing it as a pull request to hashrocket/dotmatrix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment