You can easily control the psql query buffer. Table
summarizes the commands. See the psql manual page for a full description
of each item. There is one item of particular interest, edit (\e).
This allows you to use your default editor to edit the query buffer. Type \e,
and the current contents of the query buffer are loaded into your editor. Exit
the editor, and the editor contents are reloaded into your query buffer, ready