diff options
Diffstat (limited to 'doc/src/sgml/ref/psql-ref.sgml')
-rw-r--r-- | doc/src/sgml/ref/psql-ref.sgml | 66 |
1 files changed, 51 insertions, 15 deletions
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml index 1ab200a4adc..caabb06c537 100644 --- a/doc/src/sgml/ref/psql-ref.sgml +++ b/doc/src/sgml/ref/psql-ref.sgml @@ -318,9 +318,9 @@ EOF <term><option>--no-readline</option></term> <listitem> <para> - Do not use <application>Readline</application> for line editing and do - not use the command history. - This can be useful to turn off tab expansion when cutting and pasting. + Do not use <application>Readline</application> for line editing and + do not use the command history (see + <xref linkend="app-psql-readline"/> below). </para> </listitem> </varlistentry> @@ -4562,21 +4562,47 @@ testdb=> \set PROMPT1 '%[%033[1;33;40m%]%n@%/%R%[%033[0m%]%# ' </refsect3> - <refsect3> + <refsect3 id="app-psql-readline"> <title>Command-Line Editing</title> + <indexterm> + <primary>Readline</primary> + <secondary>in psql</secondary> + </indexterm> + <indexterm> + <primary>libedit</primary> + <secondary>in psql</secondary> + </indexterm> + + <para> + <application>psql</application> uses + the <application>Readline</application> + or <application>libedit</application> library, if available, for + convenient line editing and retrieval. The command history is + automatically saved when <application>psql</application> exits and is + reloaded when <application>psql</application> starts up. Type + up-arrow or control-P to retrieve previous lines. + </para> + + <para> + You can also use tab completion to fill in partially-typed keywords + and SQL object names in many (by no means all) contexts. For example, + at the start of a command, typing <literal>ins</literal> and pressing + TAB will fill in <literal>insert into </literal>. Then, typing a few + characters of a table or schema name and pressing TAB will fill in the + unfinished name, or offer a menu of possible completions when there's + more than one. (Depending on the library in use, you may need to + press TAB more than once to get a menu.) + </para> + <para> - <application>psql</application> supports the <application>Readline</application> - library for convenient line editing and retrieval. The command - history is automatically saved when <application>psql</application> - exits and is reloaded when - <application>psql</application> starts up. Tab-completion is also - supported, although the completion logic makes no claim to be an - <acronym>SQL</acronym> parser. The queries generated by tab-completion - can also interfere with other SQL commands, e.g., <literal>SET - TRANSACTION ISOLATION LEVEL</literal>. - If for some reason you do not like the tab completion, you - can turn it off by putting this in a file named + Tab completion for SQL object names requires sending queries to the + server to find possible matches. In some contexts this can interfere + with other operations. For example, after <command>BEGIN</command> + it will be too late to issue <command>SET TRANSACTION ISOLATION + LEVEL</command> if a tab-completion query is issued in between. + If you do not want tab completion at all, you + can turn it off permanently by putting this in a file named <filename>.inputrc</filename> in your home directory: <programlisting> $if psql @@ -4587,6 +4613,16 @@ $endif <application>Readline</application> feature. Read its documentation for further details.) </para> + + <para> + The <option>-n</option> (<option>--no-readline</option>) command line + option can also be useful to disable use + of <application>Readline</application> for a single run + of <application>psql</application>. This prevents tab completion, + use or recording of command line history, and editing of multi-line + commands. It is particularly useful when you need to copy-and-paste + text that contains TAB characters. + </para> </refsect3> </refsect2> </refsect1> |