public inbox for [email protected]  
help / color / mirror / Atom feed
From: Adrian Klaver <[email protected]>
To: Rich Shepard <[email protected]>
To: [email protected]
Subject: Re: psql command line editing
Date: Wed, 12 Feb 2025 10:56:52 -0800
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>

On 2/12/25 10:50, Rich Shepard wrote:
> My web searches suggest that using the psql command line I'm limited to
> moving the cursor one character at a time. Is there a way to use a small
> editor, e.g., joe on linux, to move by words or to the begining and end of
> the line?

From:

https://www.postgresql.org/docs/current/app-psql.html

"\e or \edit [ filename ] [ line_number ]

     If filename is specified, the file is edited; after the editor 
exits, the file's content is copied into the current query buffer. If no 
filename is given, the current query buffer is copied to a temporary 
file which is then edited in the same fashion. Or, if the current query 
buffer is empty, the most recently executed query is copied to a 
temporary file and edited in the same fashion.

     If you edit a file or the previous query, and you quit the editor 
without modifying the file, the query buffer is cleared. Otherwise, the 
new contents of the query buffer are re-parsed according to the normal 
rules of psql, treating the whole buffer as a single line. Any complete 
queries are immediately executed; that is, if the query buffer contains 
or ends with a semicolon, everything up to that point is executed and 
removed from the query buffer. Whatever remains in the query buffer is 
redisplayed. Type semicolon or \g to send it, or \r to cancel it by 
clearing the query buffer.

     Treating the buffer as a single line primarily affects 
meta-commands: whatever is in the buffer after a meta-command will be 
taken as argument(s) to the meta-command, even if it spans multiple 
lines. (Thus you cannot make meta-command-using scripts this way. Use \i 
for that.)

     If a line number is specified, psql will position the cursor on the 
specified line of the file or query buffer. Note that if a single 
all-digits argument is given, psql assumes it is a line number, not a 
file name.
"

> 
> TIA,
> 
> Rich
> 
> 

-- 
Adrian Klaver
[email protected]







reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: psql command line editing
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox