Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Better syntax highlighting for PostgreSQL in VS Code

This code:

CREATE OR REPLACE TRIGGER some_trigger
    BEFORE INSERT OR DELETE OR UPDATE 
    ON some.table
    FOR EACH ROW
    EXECUTE FUNCTION some_trigger_function();

is highlighted like this:

PostgreSQL syntax highlighting

See the yellow instead of blue REPLACE or the white instead of blue FOR EACH? I suppose this is some standard sql syntax highlighting. But for PostgreSQL this is good.

I tried installing extensions like "Better PostgreSQL Syntax" or "PostgreSQL" but nothing changed.

How can I get good syntax highlighting for PostgreSQL in VS code?

like image 536
MisterMirko Avatar asked Jun 22 '26 07:06

MisterMirko


1 Answers

The extension PostgreSQL by Chris Kolkman did the trick for me in the end.

In its feature list under "Programming Languages" there are file extension *.pgsql and *.psql listed.

What I did then:

  • Disable the extensions Better PostgreSQL Syntax, SQLTools and the dependent PostgreSQL driver
  • Install PostgreSQL by Chris Kolkman
  • Rename *.sql files to *.pgsql
  • Reload the window

After that VS Code recognised the new file extensions and used the correct syntax highlighting (Language Mode "Postgres").

like image 118
MisterMirko Avatar answered Jun 25 '26 20:06

MisterMirko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!