11<!--
2- $PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.247 2010/08/03 18:33:09 tgl Exp $
2+ $PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.248 2010/08/12 00:40:59 tgl Exp $
33PostgreSQL documentation
44-->
55
@@ -1338,48 +1338,60 @@ testdb=>
13381338
13391339
13401340 <varlistentry>
1341- <term><literal>\edit</literal > (or <literal>\e</literal >) <literal><optional> <replaceable class="parameter">filename</replaceable> </optional></literal></term>
1341+ <term><literal>\edit</> (or <literal>\e</>) <literal> <optional> <replaceable class="parameter">filename</> </optional> <optional> < replaceable class="parameter">line_number</> </optional> </literal></term>
13421342
13431343 <listitem>
13441344 <para>
13451345 If <replaceable class="parameter">filename</replaceable> is
13461346 specified, the file is edited; after the editor exits, its
1347- content is copied back to the query buffer. If no argument is
1348- given, the current query buffer is copied to a temporary file
1349- which is then edited in the same fashion.
1347+ content is copied back to the query buffer. If no <replaceable
1348+ class="parameter">filename</replaceable> is given, the current query
1349+ buffer is copied to a temporary file which is then edited in the same
1350+ fashion.
13501351 </para>
13511352
13521353 <para>
13531354 The new query buffer is then re-parsed according to the normal
13541355 rules of <application>psql</application>, where the whole buffer
13551356 is treated as a single line. (Thus you cannot make scripts this
1356- way. Use <command>\i</command> for that.) This means also that
1357- if the query ends with (or rather contains) a semicolon, it is
1358- immediately executed. In other cases it will merely wait in the
1359- query buffer.
1357+ way. Use <command>\i</command> for that.) This means that
1358+ if the query ends with (or contains) a semicolon, it is
1359+ immediately executed. Otherwise it will merely wait in the
1360+ query buffer; type semicolon or <literal>\g</> to send it, or
1361+ <literal>\r</> to cancel.
13601362 </para>
13611363
13621364 <tip>
13631365 <para>
1364- <application>psql</application>searches the environment
1366+ <application>psql</application>checks the environment
13651367 variables <envar>PSQL_EDITOR</envar>, <envar>EDITOR</envar>, and
13661368 <envar>VISUAL</envar> (in that order) for an editor to use. If
13671369 all of them are unset, <filename>vi</filename> is used on Unix
13681370 systems, <filename>notepad.exe</filename> on Windows systems.
13691371 </para>
13701372 </tip>
1373+
1374+ <para>
1375+ If a line number is specified, <application>psql</application> will
1376+ position the cursor on the specified line of the file or query buffer.
1377+ This feature requires the <varname>EDITOR_LINENUMBER_SWITCH</varname>
1378+ variable to be set, so that <application>psql</application> knows how
1379+ to specify the line number to the editor. Note that if a single
1380+ all-digits argument is given, <application>psql</application> assumes
1381+ it is a line number not a file name.
1382+ </para>
13711383 </listitem>
13721384 </varlistentry>
13731385
13741386
13751387 <varlistentry>
1376- <term><literal>\ef <optional> <replaceable class="parameter">function_description</replaceable> </optional></literal></term>
1388+ <term><literal>\ef <optional> <replaceable class="parameter">function_description</> <optional> < replaceable class="parameter">line_number</> </optional> </optional> </literal></term>
13771389
13781390 <listitem>
13791391 <para>
13801392 This command fetches and edits the definition of the named function,
13811393 in the form of a <command>CREATE OR REPLACE FUNCTION</> command.
1382- Editing is done in the same way as for <literal>\e </>.
1394+ Editing is done in the same way as for <literal>\edit </>.
13831395 After the editor exits, the updated command waits in the query buffer;
13841396 type semicolon or <literal>\g</> to send it, or <literal>\r</>
13851397 to cancel.
@@ -1396,6 +1408,16 @@ testdb=>
13961408 If no function is specified, a blank <command>CREATE FUNCTION</>
13971409 template is presented for editing.
13981410 </para>
1411+
1412+ <para>
1413+ If a line number is specified, <application>psql</application> will
1414+ position the cursor on the specified line of the function body
1415+ (note that the function body typically does not begin on the
1416+ first line of the file).
1417+ This feature requires the <varname>EDITOR_LINENUMBER_SWITCH</varname>
1418+ variable to be set, so that <application>psql</application> knows how
1419+ to specify the line number to the editor.
1420+ </para>
13991421 </listitem>
14001422 </varlistentry>
14011423
@@ -2457,6 +2479,27 @@ bar
24572479 </listitem>
24582480 </varlistentry>
24592481
2482+ <varlistentry>
2483+ <term><varname>EDITOR_LINENUMBER_SWITCH</varname></term>
2484+ <listitem>
2485+ <para>
2486+ When <command>\edit</command> or <command>\ef</command> is used with a
2487+ line number argument, this variable specifies the command-line switch
2488+ used to pass the line number to the user's editor. For editors such
2489+ as <productname>emacs</> or <productname>vi</>, you can simply set
2490+ this variable to a plus sign. Include a trailing space in the value
2491+ of the variable if there needs to be space between the switch name and
2492+ the line number.
2493+ Examples:
2494+
2495+ <programlisting>
2496+ \set EDITOR_LINENUMBER_SWITCH +
2497+ \set EDITOR_LINENUMBER_SWITCH '--line '
2498+ </programlisting>
2499+ </para>
2500+ </listitem>
2501+ </varlistentry>
2502+
24602503 <varlistentry>
24612504 <term><varname>ENCODING</varname></term>
24622505 <listitem>