Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tiIQE-00E65F-UA for pgsql-general@arkaria.postgresql.org; Wed, 12 Feb 2025 19:29:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tiIQB-00CwGz-8d for pgsql-general@arkaria.postgresql.org; Wed, 12 Feb 2025 19:29:19 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tiIQA-00CwG1-TQ for pgsql-general@lists.postgresql.org; Wed, 12 Feb 2025 19:29:19 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tiIQ9-000SKW-30 for pgsql-general@postgresql.org; Wed, 12 Feb 2025 19:29:18 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 51CJTFY73370942; Wed, 12 Feb 2025 14:29:15 -0500 From: Tom Lane To: Ron Johnson cc: Rich Shepard , pgsql-general Subject: Re: psql command line editing In-reply-to: References: <61255ab-6249-1226-7db6-4ecc3e4c127b@appl-ecosys.com> Comments: In-reply-to Ron Johnson message dated "Wed, 12 Feb 2025 13:55:04 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <3370940.1739388555.1@sss.pgh.pa.us> Content-Transfer-Encoding: 8bit Date: Wed, 12 Feb 2025 14:29:15 -0500 Message-ID: <3370941.1739388555@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Ron Johnson writes: > On Wed, Feb 12, 2025 at 1:50 PM 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? > The PGDG prebuilt packages are built with libreadline. Thus, if that's how > you installed psql, Home, End, Ctrl-Left, Ctrl-Right and Ctrl-w should work. On my machine, Ctrl-Left/Right don't seem to do anything, but the usual Emacs combinations Ctrl-A, Ctrl-E, Escape-B, Escape-F and so on work in psql. I don't believe I did anything special to configure that. Check your local readline documentation. As Adrian notes, there's also \e, which is good for entering or editing multi-line queries. regards, tom lane