A very simple plugin to enable SQL syntax highlighting inside strings in a Java file. If you can handle the visual trip of two syntax highlighters co-existing, this plugin will provide.
- Install Pathogen. (You're already using Pathogen, right?)
- Clone this project into
~/.vim/bundle/vim-java-sql
.
Whenever you edit a Java file, strings starting with "SELECT
, "INSERT
,
"UPDATE
, "DELETE
, "CREATE
or "DROP
will be highlighted as SQL.
Matches are case-sensitive, because that's my preference, but it's trivial to fork & change the matching rules to suit your coding style.
This repo serves as a reasonable recipe for embedded Vim syntax highlighting in general. It could easily be forked for highlighting SQL in Hibernate XML files, for example.
Thanks to Max Bane who figured out the hard stuff when when mixing Tex with Python.
vim-clojure-sql - the same plugin for SQL inside Clojure files.