I am aware of using \e in psql to edit the query in the buffer.

But what if you are currently creating the query for the first time and want to jump to the editor?

Or better, you go through history to a previous, expensive, query and want to add some edits before.

A nasty trick could be going to the first char of the line an add a comment (/*) and the same at the end, but something like C-xC-e in the shell will be great.


Don't write a trailing semicolon. If you go through the history, remove the trailing semicolon. That will put the query in the buffer, and you can edit it with \e.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.