Ireneusz Pluta pisze:
Or invoked with its -c"set syntax=sql" command line switch. So, the whole question is how to have psql to tell vim which particular syntax to use, in one of these ways.

OK, after real RTFM of man psql in this area:

              Tip: psql searches the environment variables  PSQL_EDITOR,  EDI-
              TOR,  and VISUAL (in that order) for an editor to use. If all of
              them are unset, vi is used on Unix systems, notepad.exe on  Win-
              dows systems.

I found the solution by setting the PSQL_EDITOR to 'vim -c"set syntax=sql"'.
It works now the way I want.

Thanks