
* On Unix the EDITOR value should *not* be quoted, since it might include

Let’s try to examine the psql sources to find out if we can set PSQL_EDITOR to an arbitrary command line: '"C:\Program Files\Sublime Text 3\subl.exe -w"' is not recognized asĪn internal or external command, operable program or batch file. $ SET PSQL_EDITOR=C:\Program Files\Sublime Text 3\subl.exe -w But the problem is: we cannot pass additional command line options in Windows:

Specifying -w will cause the subl command to not exit until the file is closed. Next time you try to execute \e, it reports on the temp file’s existence. So psql gets a signal about subl, finishes and returns, but the temp file hasn’t even been edited yet. But subl is a special tool, which in fact launches sublime.exe and then just dies. Psql runs the editor and then waits for the editor process to finish. This can be used to open files and projects in Sublime Text, and also works as an EDITOR for unix tools, such as git and subversion. Sublime Text includes a command line tool, subl, to work with files on the command line. What’s wrong here? First of all, I’ve used subl.exe instead of sublime.exe, which is special command line tool: $ SET PSQL_EDITOR=C:\Program Files\Sublime Text 3\subl.exeĬould not open temporary file "C:\Temp\": File existsĪs you can see, nothing was executed after the first \e command, even though I’ve edited and saved the content of the query. Let’s try to set the environment variable then.
SUBLIME TEXT EDITOR FOR WINDOWS 10 MANUAL
PSQL_EDITOR – an environment variableĪccording to the manual PSQL_EDITOR, EDITOR and VISUAL are environment variables, which are used inside psql to call an editor for input. I’ve chosen Sublime as a target because it’s not a simple console or single window application, but rather an advanced text processor with enhanced file handling, e.g. Who knows what Microsoft’s next purchase will be? After LinkedIn, GitHub, and Citus, you cannot be sure anymore! 😉 The Sublime text processor for the PSQL_EDITOR variable If you, my dear reader, are a Linux user, I’m sure you will also find this information useful anyway.

Still, there is a lack of such tips for Windows users. There is a lot of information about tweaking psql in POSIX environments. All tests were done on Windows 10 with PostgreSQL 12 installed.Īs you know, PostgreSQL ships with an interactive console tool named psql, which allows you to use a lot of enhanced features, like watching, for example.
SUBLIME TEXT EDITOR FOR WINDOWS 10 FULL
While trying to figure out all possible pitfalls, I’ve somehow managed to write a full blog post. This is a How-To blog about the PSQL_EDITOR variable.
