file. This is useful when the expanded string will be used in a shell command, such as in LESSEDIT.
%i Replaced by the index of the current file in the list of input files.
%lX Replaced by the line number of a line in the input file. The line to be used is determined by the X, as with the %b option.
%L Replaced by the line number of the last line in the input file.
%m Replaced by the total number of input files.
%pX Replaced by the percent into the current input file, based on byte offsets. The line used is determined by the X as with the %b option.
%PX Replaced by the percent into the current input file, based on line numbers. The line used is determined by the X as with the %b option.
%s Same as %B.
%t Causes any trailing spaces to be removed. Usually used at the end of the string, but may appear anywhere.
%T Normally expands to the word "file". However if viewing files via a tags list using the -t option, it expands to the word "tag".
%x Replaced by the name of the next input file in the list.
If any item is unknown (for example, the file size if input is a pipe), a question mark is printed instead.
The format of the prompt string can be changed depending on certain conditions. A question mark followed by a single character acts like an "IF": depending on the following character, a condition is evaluated. If
the condition is true, any characters following the question mark and condition character, up to a period, are included in the prompt. If the condition is false, such characters are not included. A colon appearing
between the question mark and the period can be used to establish an "ELSE": any characters between the colon and the period are included in the string if and only if the IF condition is false. Condition characters
(which follow a question mark) may be:
?a True if any characters have been included in the prompt so far.
?bX True if the byte offset of the specified line is known.
?B True if the size of current input file is known.
?c True if the text is horizontally shifted (%c is not zero).
?dX True if the page number of the specified line is known.
?e True if at end‐of‐file.
?f True if there is an input filename (that is, if input is not a pipe).
?lX True if the line number of the specified line is known.
?L True if the line number of the last line in the file is known.
?m True if there is more than one input file.
?n True if this is the first prompt in a new input file.
?pX True if the percent into the current input file, based on byte offsets, of the specified line is known.
?PX True if the percent into the current input file, based on line numbers, of the specified line is known.
?s Same as "?B".
?x True if there is a next input file (that is, if the current input file is not the last one).
Any characters other than the special ones (question mark, colon, period, percent, and backslash) become literally part of the prompt. Any of the special characters may be included in the prompt literally by preced‐
ing it with a backslash.
Some examples:
?f%f:Standard input.
This prompt prints the filename, if known; otherwise the string "Standard input".
?f%f .?ltLine %lt:?pt%pt\%:?btByte %bt:‐...
This prompt would print the filename, if known. The filename is followed by the line number, if known, otherwise the percent if known, otherwise the byte offset if known. Otherwise, a dash is printed. Notice how
each question mark has a matching period, and how the % after the %pt is included literally by escaping it with a backslash.
?n?f%f .?m(%T %i of %m) ..?e(END) ?x‐ Next\: %x..%t";
This prints