Skip to content

Instantly share code, notes, and snippets.

@reinh
Last active February 20, 2016 00:39
Show Gist options
  • Save reinh/5448512 to your computer and use it in GitHub Desktop.
Save reinh/5448512 to your computer and use it in GitHub Desktop.

Revisions

  1. reinh revised this gist Apr 24, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    ### Syntax highlight SQL inside Ruby `<<-SQL` heredocs
    ## Syntax highlight SQL inside Ruby `<<-SQL` heredocs

    Embeds SQL syntax highlighting inside Ruby heredocs labeled `SQL`. This will also work to embed other syntaxen, e.g., HTML.

  2. reinh revised this gist Apr 24, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,8 @@
    ## Syntax highlight SQL inside Ruby `<<-SQL` heredocs
    ### Syntax highlight SQL inside Ruby `<<-SQL` heredocs

    Embeds SQL syntax highlighting inside Ruby heredocs labeled `SQL`. This will also work to embed other syntaxen, e.g., HTML.

    ### Optional PGSQL enhanced syntax:
    #### Optional PGSQL enhanced syntax:

    (requires https://github.com/exu/pgsql.vim)

  3. reinh revised this gist Apr 24, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,7 @@ Embeds SQL syntax highlighting inside Ruby heredocs labeled `SQL`. This will als
    syntax include @SQL syntax/pgsql.vim
    ```

    ### Credits
    #### Credits:

    * http://blogs.perl.org/users/ovid/2011/06/syntax-highlight-your-sql-heredocs-in-vim.html
    * http://stackoverflow.com/questions/6864420/change-filetype-or-other-vim-settings-blockwise-in-a-file
  4. reinh revised this gist Apr 24, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@

    Embeds SQL syntax highlighting inside Ruby heredocs labeled `SQL`. This will also work to embed other syntaxen, e.g., HTML.

    ## Optional PGSQL enhanced syntax:
    ### Optional PGSQL enhanced syntax:

    (requires https://github.com/exu/pgsql.vim)

  5. reinh revised this gist Apr 24, 2013. 1 changed file with 5 additions and 3 deletions.
    8 changes: 5 additions & 3 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,10 @@
    ## Syntax highlight SQL inside `<<-SQL` heredocs
    ## Syntax highlight SQL inside Ruby `<<-SQL` heredocs

    Similar principle will work to embed other syntaxen, e.g., HTML.
    Embeds SQL syntax highlighting inside Ruby heredocs labeled `SQL`. This will also work to embed other syntaxen, e.g., HTML.

    Optional: requires https://github.com/exu/pgsql.vim
    ## Optional PGSQL enhanced syntax:

    (requires https://github.com/exu/pgsql.vim)

    ```VimL
    syntax include @SQL syntax/pgsql.vim
  6. reinh revised this gist Apr 24, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    Syntax highlight SQL inside `<<-SQL` heredocs
    ## Syntax highlight SQL inside `<<-SQL` heredocs

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

  7. reinh revised this gist Apr 24, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,7 @@ Optional: requires https://github.com/exu/pgsql.vim
    syntax include @SQL syntax/pgsql.vim
    ```

    **Credits:**
    ### Credits

    * http://blogs.perl.org/users/ovid/2011/06/syntax-highlight-your-sql-heredocs-in-vim.html
    * http://stackoverflow.com/questions/6864420/change-filetype-or-other-vim-settings-blockwise-in-a-file
  8. reinh revised this gist Apr 24, 2013. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -7,3 +7,8 @@ Optional: requires https://github.com/exu/pgsql.vim
    ```VimL
    syntax include @SQL syntax/pgsql.vim
    ```

    **Credits:**

    * http://blogs.perl.org/users/ovid/2011/06/syntax-highlight-your-sql-heredocs-in-vim.html
    * http://stackoverflow.com/questions/6864420/change-filetype-or-other-vim-settings-blockwise-in-a-file
  9. reinh revised this gist Apr 24, 2013. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion ruby-embedded-sql-heredocs.vim
    Original file line number Diff line number Diff line change
    @@ -1,12 +1,13 @@
    " ~/.vim/after/syntax/ruby.vim

    " Save and restore buffer's current syntax
    " 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)
  10. reinh revised this gist Apr 24, 2013. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion ruby-embedded-sql-heredocs.vim
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,13 @@
    " ~/.vim/after/syntax/ruby.vim

    " Save and restore buffer's current syntax
    let s:bcs = b:current_syntax
    unlet b:current_syntax

    " Magic happens here.
    syntax include @SQL syntax/sql.vim

    let b:current_syntax = s:bcs

    syntax region rubyHereDocSQL matchgroup=Statement start=+<<-\?SQL+ end=+^\s*SQL$+ contains=@SQL
    " Match Ruby heredoc format (`<<` or `<<-` start tag, whitespace before end tag)
    syntax region rubyHereDocSQL matchgroup=Statement start=+<<-\?SQL+ end=+^\s*SQL$+ contains=@SQL
  11. reinh created this gist Apr 24, 2013.
    9 changes: 9 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    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

    ```VimL
    syntax include @SQL syntax/pgsql.vim
    ```
    9 changes: 9 additions & 0 deletions ruby-embedded-sql-heredocs.vim
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    " ~/.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