\p

\p prints the current query buffer to the standard output. For example:

=> \p
CREATE VIEW my_seqview AS (SELECT * FROM sequences);