title: Use psql's \copy for a multi-line query
body: <p>This is a follow-up question from <a href="https://stackoverflow.com/a/1517692/327026">this answer</a> for "<a href="https://stackoverflow.com/q/1517635/327026">Save PL/pgSQL output from PostgreSQL to a CSV file</a>".</p>
  
  <p>I need to write a client-side CSV file using psql's <a href="https://www.postgresql.org/docs/current/static/app-psql.html#APP-PSQL-META-COMMANDS-COPY" rel="noreferrer"><code>\copy</code> command</a>. A one liner works:
  </p>
  
  <pre><code>db=&gt; \copy (select 1 AS foo) to 'bar.csv' csv header
  COPY 1
  </code></pre>
  
  <p>However, I have long queries that span several lines. I don't need to show the query, as I can't seem to extend this past one line without a parse error:
  </p>
  
  <pre><code>db=&gt; \copy (
  \copy: parse error at end of line
  db=&gt; \copy ( \\
  \copy: parse error at end of line
  db=&gt; \copy ("
  \copy: parse error at end of line
  db=&gt; \copy "(
  \copy: parse error at end of line
  db=&gt; \copy \\
  \copy: parse error at end of line
  </code></pre>
  
  <p>Is it possible to use <code>\copy</code> with a query that spans multiple lines? I'm using psql on Windows.</p>