简体   繁体   中英

Real SQL syntax highlighting in PHP scripts with Vim

I know it's possible to enable SQL syntax highlighting in PHP scripts using the option

let php_sql_query=1

But this just enables highlighting of all SQL keywords in every string. Even in a normal sentence like this one.

Is there a way to only enable this for strings starting with "Select", "update" or "delete"?

Enclosing the query in a heredoc with an identifier of "SQL" triggers Vim to do SQL syntax highlighting in the block, eg:

$q = <<<SQL
        SELECT `foo`
        FROM `db`.`table`
        WHERE `foo` = 'bar'
SQL;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM