Re: psql command line editing - Mailing list pgsql-general

From Adrian Klaver
Subject Re: psql command line editing
Date
Msg-id bdb872db-6c35-4faf-8b4a-3011bd181850@aklaver.com
Whole thread Raw
In response to psql command line editing  (Rich Shepard <rshepard@appl-ecosys.com>)
List pgsql-general
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
adrian.klaver@aklaver.com




pgsql-general by date:

Previous
From: Ron Johnson
Date:
Subject: Re: psql command line editing
Next
From: Tom Lane
Date:
Subject: Re: psql command line editing