Import less-436.
[dragonfly.git] / contrib / less / less.nro
CommitLineData
a9adbba3 1.TH LESS 1 "Version 436: 07 Jul 2009"
131ccf9c
PA
2.SH NAME
3less \- opposite of more
4.SH SYNOPSIS
5.B "less \-?"
6.br
7.B "less \-\-help"
8.br
9.B "less \-V"
10.br
11.B "less \-\-version"
12.br
13.B "less [\-[+]aBcCdeEfFgGiIJKLmMnNqQrRsSuUVwWX~]"
14.br
15.B " [\-b \fIspace\fP] [\-h \fIlines\fP] [\-j \fIline\fP] [\-k \fIkeyfile\fP]"
16.br
17.B " [\-{oO} \fIlogfile\fP] [\-p \fIpattern\fP] [\-P \fIprompt\fP] [\-t \fItag\fP]"
18.br
19.B " [\-T \fItagsfile\fP] [\-x \fItab\fP,...] [\-y \fIlines\fP] [\-[z] \fIlines\fP]"
20.br
21.B " [\-# \fIshift\fP] [+[+]\fIcmd\fP] [\-\-] [\fIfilename\fP]..."
22.br
23(See the OPTIONS section for alternate option syntax with long option names.)
24
25.SH DESCRIPTION
26.I Less
27is a program similar to
28.I more
29(1), but which allows backward movement
30in the file as well as forward movement.
31Also,
32.I less
33does not have to read the entire input file before starting,
34so with large input files it starts up faster than text editors like
35.I vi
36(1).
37.I Less
38uses termcap (or terminfo on some systems),
39so it can run on a variety of terminals.
40There is even limited support for hardcopy terminals.
41(On a hardcopy terminal, lines which should be printed at the top
42of the screen are prefixed with a caret.)
43.PP
44Commands are based on both
45.I more
46and
47.I vi.
48Commands may be preceded by a decimal number,
49called N in the descriptions below.
50The number is used by some commands, as indicated.
51
52.SH COMMANDS
53In the following descriptions, ^X means control-X.
54ESC stands for the ESCAPE key; for example ESC-v means the
55two character sequence "ESCAPE", then "v".
56.IP "h or H"
57Help: display a summary of these commands.
58If you forget all the other commands, remember this one.
59.IP "SPACE or ^V or f or ^F"
60Scroll forward N lines, default one window (see option \-z below).
61If N is more than the screen size, only the final screenful is displayed.
62Warning: some systems use ^V as a special literalization character.
63.IP "z"
64Like SPACE, but if N is specified, it becomes the new window size.
65.IP "ESC-SPACE"
66Like SPACE, but scrolls a full screenful, even if it reaches
67end-of-file in the process.
68.IP "RETURN or ^N or e or ^E or j or ^J"
69Scroll forward N lines, default 1.
70The entire N lines are displayed, even if N is more than the screen size.
71.IP "d or ^D"
72Scroll forward N lines, default one half of the screen size.
73If N is specified, it becomes the new default for
74subsequent d and u commands.
75.IP "b or ^B or ESC-v"
76Scroll backward N lines, default one window (see option \-z below).
77If N is more than the screen size, only the final screenful is displayed.
78.IP "w"
79Like ESC-v, but if N is specified, it becomes the new window size.
80.IP "y or ^Y or ^P or k or ^K"
81Scroll backward N lines, default 1.
82The entire N lines are displayed, even if N is more than the screen size.
83Warning: some systems use ^Y as a special job control character.
84.IP "u or ^U"
85Scroll backward N lines, default one half of the screen size.
86If N is specified, it becomes the new default for
87subsequent d and u commands.
88.IP "ESC-) or RIGHTARROW"
89Scroll horizontally right N characters, default half the screen width
90(see the \-# option).
91If a number N is specified, it becomes the default for future RIGHTARROW
92and LEFTARROW commands.
93While the text is scrolled, it acts as though the \-S option
94(chop lines) were in effect.
95.IP "ESC-( or LEFTARROW"
96Scroll horizontally left N characters, default half the screen width
97(see the \-# option).
98If a number N is specified, it becomes the default for future RIGHTARROW
99and LEFTARROW commands.
100.IP "r or ^R or ^L"
101Repaint the screen.
102.IP R
103Repaint the screen, discarding any buffered input.
104Useful if the file is changing while it is being viewed.
105.IP "F"
106Scroll forward, and keep trying to read when the
107end of file is reached.
108Normally this command would be used when already at the end of the file.
109It is a way to monitor the tail of a file which is growing
110while it is being viewed.
111(The behavior is similar to the "tail \-f" command.)
112.IP "g or < or ESC-<"
113Go to line N in the file, default 1 (beginning of file).
114(Warning: this may be slow if N is large.)
115.IP "G or > or ESC->"
116Go to line N in the file, default the end of the file.
117(Warning: this may be slow if N is large,
118or if N is not specified and
119standard input, rather than a file, is being read.)
120.IP "p or %"
121Go to a position N percent into the file.
122N should be between 0 and 100, and may contain a decimal point.
123.IP "P"
124Go to the line containing byte offset N in the file.
125.IP "{"
126If a left curly bracket appears in the top line displayed
127on the screen,
128the { command will go to the matching right curly bracket.
129The matching right curly bracket is positioned on the bottom
130line of the screen.
131If there is more than one left curly bracket on the top line,
132a number N may be used to specify the N-th bracket on the line.
133.IP "}"
134If a right curly bracket appears in the bottom line displayed
135on the screen,
136the } command will go to the matching left curly bracket.
137The matching left curly bracket is positioned on the top
138line of the screen.
139If there is more than one right curly bracket on the top line,
140a number N may be used to specify the N-th bracket on the line.
141.IP "("
142Like {, but applies to parentheses rather than curly brackets.
143.IP ")"
144Like }, but applies to parentheses rather than curly brackets.
145.IP "["
146Like {, but applies to square brackets rather than curly brackets.
147.IP "]"
148Like }, but applies to square brackets rather than curly brackets.
149.IP "ESC-^F"
150Followed by two characters,
151acts like {, but uses the two characters as open and close brackets,
152respectively.
153For example, "ESC ^F < >" could be used to
154go forward to the > which matches the < in the top displayed line.
155.IP "ESC-^B"
156Followed by two characters,
157acts like }, but uses the two characters as open and close brackets,
158respectively.
159For example, "ESC ^B < >" could be used to
160go backward to the < which matches the > in the bottom displayed line.
161.IP m
162Followed by any lowercase letter,
163marks the current position with that letter.
164.IP "'"
165(Single quote.)
166Followed by any lowercase letter, returns to the position which
167was previously marked with that letter.
168Followed by another single quote, returns to the position at
169which the last "large" movement command was executed.
170Followed by a ^ or $, jumps to the beginning or end of the
171file respectively.
172Marks are preserved when a new file is examined,
173so the ' command can be used to switch between input files.
174.IP "^X^X"
175Same as single quote.
176.IP /pattern
177Search forward in the file for the N-th line containing the pattern.
178N defaults to 1.
179The pattern is a regular expression, as recognized by
180the regular expression library supplied by your system.
181The search starts at the second line displayed
182(but see the \-a and \-j options, which change this).
183.sp
184Certain characters are special
185if entered at the beginning of the pattern;
186they modify the type of search rather than become part of the pattern:
187.RS
188.IP "^N or !"
189Search for lines which do NOT match the pattern.
190.IP "^E or *"
191Search multiple files.
192That is, if the search reaches the END of the current file
193without finding a match,
194the search continues in the next file in the command line list.
195.IP "^F or @"
196Begin the search at the first line of the FIRST file
197in the command line list,
198regardless of what is currently displayed on the screen
199or the settings of the \-a or \-j options.
200.IP "^K"
201Highlight any text which matches the pattern on the current screen,
202but don't move to the first match (KEEP current position).
203.IP "^R"
204Don't interpret regular expression metacharacters;
205that is, do a simple textual comparison.
206.RE
207.IP ?pattern
208Search backward in the file for the N-th line containing the pattern.
209The search starts at the line immediately before the top line displayed.
210.sp
211Certain characters are special as in the / command:
212.RS
213.IP "^N or !"
214Search for lines which do NOT match the pattern.
215.IP "^E or *"
216Search multiple files.
217That is, if the search reaches the beginning of the current file
218without finding a match,
219the search continues in the previous file in the command line list.
220.IP "^F or @"
221Begin the search at the last line of the last file
222in the command line list,
223regardless of what is currently displayed on the screen
224or the settings of the \-a or \-j options.
225.IP "^K"
226As in forward searches.
227.IP "^R"
228As in forward searches.
229.RE
230.IP "ESC-/pattern"
231Same as "/*".
232.IP "ESC-?pattern"
233Same as "?*".
234.IP n
235Repeat previous search, for N-th line containing the last pattern.
236If the previous search was modified by ^N, the search is made for the
237N-th line NOT containing the pattern.
238If the previous search was modified by ^E, the search continues
239in the next (or previous) file if not satisfied in the current file.
240If the previous search was modified by ^R, the search is done
241without using regular expressions.
242There is no effect if the previous search was modified by ^F or ^K.
243.IP N
244Repeat previous search, but in the reverse direction.
245.IP "ESC-n"
246Repeat previous search, but crossing file boundaries.
247The effect is as if the previous search were modified by *.
248.IP "ESC-N"
249Repeat previous search, but in the reverse direction
250and crossing file boundaries.
251.IP "ESC-u"
252Undo search highlighting.
253Turn off highlighting of strings matching the current search pattern.
254If highlighting is already off because of a previous ESC-u command,
255turn highlighting back on.
256Any search command will also turn highlighting back on.
257(Highlighting can also be disabled by toggling the \-G option;
258in that case search commands do not turn highlighting back on.)
8be36e5b
PA
259.IP "&pattern"
260Display only lines which match the pattern;
261lines which do not match the pattern are not displayed.
262If pattern is empty (if you type & immediately followed by ENTER),
263any filtering is turned off, and all lines are displayed.
264While filtering is in effect, an ampersand is displayed at the
265beginning of the prompt,
266as a reminder that some lines in the file may be hidden.
267.sp
268Certain characters are special as in the / command:
269.RS
270.IP "^N or !"
271Display only lines which do NOT match the pattern.
272.IP "^R"
273Don't interpret regular expression metacharacters;
274that is, do a simple textual comparison.
275.RE
131ccf9c
PA
276.IP ":e [filename]"
277Examine a new file.
278If the filename is missing, the "current" file (see the :n and :p commands
279below) from the list of files in the command line is re-examined.
280A percent sign (%) in the filename is replaced by the name of the
281current file.
282A pound sign (#) is replaced by the name of the previously examined file.
283However, two consecutive percent signs are simply
284replaced with a single percent sign.
285This allows you to enter a filename that contains a percent sign
286in the name.
287Similarly, two consecutive pound signs are replaced with a single pound sign.
288The filename is inserted into the command line list of files
289so that it can be seen by subsequent :n and :p commands.
290If the filename consists of several files, they are all inserted into
291the list of files and the first one is examined.
292If the filename contains one or more spaces,
293the entire filename should be enclosed in double quotes
294(also see the \-" option).
295.IP "^X^V or E"
296Same as :e.
297Warning: some systems use ^V as a special literalization character.
298On such systems, you may not be able to use ^V.
299.IP ":n"
300Examine the next file (from the list of files given in the command line).
301If a number N is specified, the N-th next file is examined.
302.IP ":p"
303Examine the previous file in the command line list.
304If a number N is specified, the N-th previous file is examined.
305.IP ":x"
306Examine the first file in the command line list.
307If a number N is specified, the N-th file in the list is examined.
308.IP ":d"
309Remove the current file from the list of files.
310.IP "t"
311Go to the next tag, if there were more than one matches for the current tag.
312See the \-t option for more details about tags.
313.IP "T"
314Go to the previous tag, if there were more than one matches for the current tag.
315.IP "= or ^G or :f"
316Prints some information about the file being viewed,
317including its name
318and the line number and byte offset of the bottom line being displayed.
319If possible, it also prints the length of the file,
320the number of lines in the file
321and the percent of the file above the last displayed line.
322.IP \-
323Followed by one of the command line option letters (see OPTIONS below),
324this will change the setting of that option
325and print a message describing the new setting.
326If a ^P (CONTROL-P) is entered immediately after the dash,
327the setting of the option is changed but no message is printed.
328If the option letter has a numeric value (such as \-b or \-h),
329or a string value (such as \-P or \-t),
330a new value may be entered after the option letter.
331If no new value is entered, a message describing
332the current setting is printed and nothing is changed.
333.IP \-\-
334Like the \- command, but takes a long option name (see OPTIONS below)
335rather than a single option letter.
336You must press RETURN after typing the option name.
337A ^P immediately after the second dash suppresses printing of a
338message describing the new setting, as in the \- command.
339.IP \-+
340Followed by one of the command line option letters
341this will reset the option to its default setting
342and print a message describing the new setting.
343(The "\-+\fIX\fP" command does the same thing
344as "\-+\fIX\fP" on the command line.)
345This does not work for string-valued options.
346.IP \-\-+
347Like the \-+ command, but takes a long option name
348rather than a single option letter.
349.IP \-!
350Followed by one of the command line option letters,
351this will reset the option to the "opposite" of its default setting
352and print a message describing the new setting.
353This does not work for numeric or string-valued options.
354.IP \-\-!
355Like the \-! command, but takes a long option name
356rather than a single option letter.
357.IP _
358(Underscore.)
359Followed by one of the command line option letters,
360this will print a message describing the current setting of that option.
361The setting of the option is not changed.
362.IP __
363(Double underscore.)
364Like the _ (underscore) command, but takes a long option name
365rather than a single option letter.
366You must press RETURN after typing the option name.
367.IP +cmd
368Causes the specified cmd to be executed each time a new file is examined.
369For example, +G causes
370.I less
371to initially display each file starting at the end
372rather than the beginning.
373.IP V
374Prints the version number of
375.I less
376being run.
377.IP "q or Q or :q or :Q or ZZ"
378Exits
379.I less.
380.PP
381The following
382four
383commands may or may not be valid, depending on your particular installation.
384.PP
385.IP v
386Invokes an editor to edit the current file being viewed.
387The editor is taken from the environment variable VISUAL if defined,
388or EDITOR if VISUAL is not defined,
389or defaults to "vi" if neither VISUAL nor EDITOR is defined.
390See also the discussion of LESSEDIT under the section on PROMPTS below.
391.IP "! shell-command"
392Invokes a shell to run the shell-command given.
393A percent sign (%) in the command is replaced by the name of the
394current file.
395A pound sign (#) is replaced by the name of the previously examined file.
396"!!" repeats the last shell command.
397"!" with no shell command simply invokes a shell.
398On Unix systems, the shell is taken from the environment variable SHELL,
399or defaults to "sh".
400On MS-DOS and OS/2 systems, the shell is the normal command processor.
401.IP "| <m> shell-command"
402<m> represents any mark letter.
403Pipes a section of the input file to the given shell command.
404The section of the file to be piped is between the first line on
405the current screen and the position marked by the letter.
406<m> may also be ^ or $ to indicate beginning or end of file respectively.
407If <m> is . or newline, the current screen is piped.
408.IP "s filename"
409Save the input to a file.
410This only works if the input is a pipe, not an ordinary file.
411.PP
412.SH OPTIONS
413Command line options are described below.
414Most options may be changed while
415.I less
416is running, via the "\-" command.
417.PP
418Most options may be given in one of two forms:
419either a dash followed by a single letter,
420or two dashes followed by a long option name.
421A long option name may be abbreviated as long as
422the abbreviation is unambiguous.
423For example, \-\-quit-at-eof may be abbreviated \-\-quit, but not
424--qui, since both \-\-quit-at-eof and \-\-quiet begin with \-\-qui.
425Some long option names are in uppercase, such as \-\-QUIT-AT-EOF, as
426distinct from \-\-quit-at-eof.
427Such option names need only have their first letter capitalized;
428the remainder of the name may be in either case.
429For example, \-\-Quit-at-eof is equivalent to \-\-QUIT-AT-EOF.
430.PP
431Options are also taken from the environment variable "LESS".
432For example,
433to avoid typing "less \-options ..." each time
434.I less
435is invoked, you might tell
436.I csh:
437.sp
438setenv LESS "-options"
439.sp
440or if you use
441.I sh:
442.sp
443LESS="-options"; export LESS
444.sp
445On MS-DOS, you don't need the quotes, but you should replace any
446percent signs in the options string by double percent signs.
447.sp
448The environment variable is parsed before the command line,
449so command line options override the LESS environment variable.
450If an option appears in the LESS variable, it can be reset
451to its default value on the command line by beginning the command
452line option with "\-+".
453.sp
454For options like \-P or \-D which take a following string,
455a dollar sign ($) must be used to signal the end of the string.
456For example, to set two \-D options on MS-DOS, you must have
457a dollar sign between them, like this:
458.sp
459LESS="-Dn9.1$-Ds4.1"
460.sp
461.IP "\-? or \-\-help"
462This option displays a summary of the commands accepted by
463.I less
464(the same as the h command).
465(Depending on how your shell interprets the question mark,
466it may be necessary to quote the question mark, thus: "\-\e?".)
467.IP "\-a or \-\-search-skip-screen"
468Causes searches to start after the last line
469displayed on the screen,
470thus skipping all lines displayed on the screen.
471By default, searches start at the second line on the screen
472(or after the last found line; see the \-j option).
473.IP "\-b\fIn\fP or \-\-buffers=\fIn\fP"
474Specifies the amount of buffer space
475.I less
476will use for each file, in units of kilobytes (1024 bytes).
477By default 64K of buffer space is used for each file
478(unless the file is a pipe; see the \-B option).
479The \-b option specifies instead that \fIn\fP kilobytes of
480buffer space should be used for each file.
481If \fIn\fP is \-1, buffer space is unlimited; that is,
1df93143 482the entire file can be read into memory.
131ccf9c
PA
483.IP "\-B or \-\-auto-buffers"
484By default, when data is read from a pipe,
485buffers are allocated automatically as needed.
486If a large amount of data is read from the pipe, this can cause
487a large amount of memory to be allocated.
488The \-B option disables this automatic allocation of buffers for pipes,
489so that only 64K
490(or the amount of space specified by the \-b option)
491is used for the pipe.
492Warning: use of \-B can result in erroneous display, since only the
1df93143 493most recently viewed part of the piped data is kept in memory;
131ccf9c
PA
494any earlier data is lost.
495.IP "\-c or \-\-clear-screen"
496Causes full screen repaints to be painted from the top line down.
497By default,
498full screen repaints are done by scrolling from the bottom of the screen.
499.IP "\-C or \-\-CLEAR-SCREEN"
500Same as \-c, for compatibility with older versions of
501.I less.
502.IP "\-d or \-\-dumb"
503The \-d option suppresses the error message
504normally displayed if the terminal is dumb;
505that is, lacks some important capability,
506such as the ability to clear the screen or scroll backward.
507The \-d option does not otherwise change the behavior of
508.I less
509on a dumb terminal.
510.IP "\-D\fBx\fP\fIcolor\fP or \-\-color=\fBx\fP\fIcolor\fP"
511[MS-DOS only]
512Sets the color of the text displayed.
513\fBx\fP is a single character which selects the type of text whose color is
514being set: n=normal, s=standout, d=bold, u=underlined, k=blink.
515\fIcolor\fP is a pair of numbers separated by a period.
516The first number selects the foreground color and the second selects
517the background color of the text.
8be36e5b
PA
518A single number \fIN\fP is the same as \fIN.M\fP,
519where \fIM\fP is the normal background color.
520
131ccf9c
PA
521.IP "\-e or \-\-quit-at-eof"
522Causes
523.I less
524to automatically exit
525the second time it reaches end-of-file.
526By default, the only way to exit
527.I less
528is via the "q" command.
529.IP "\-E or \-\-QUIT-AT-EOF"
530Causes
531.I less
532to automatically exit the first time it reaches end-of-file.
533.IP "\-f or \-\-force"
534Forces non-regular files to be opened.
535(A non-regular file is a directory or a device special file.)
536Also suppresses the warning message when a binary file is opened.
537By default,
538.I less
539will refuse to open non-regular files.
540Note that some operating systems will not allow directories
541to be read, even if \-f is set.
542.IP "\-F or \-\-quit-if-one-screen"
543Causes
544.I less
545to automatically exit
546if the entire file can be displayed on the first screen.
547.IP "\-g or \-\-hilite-search"
548Normally,
549.I less
550will highlight ALL strings which match the last search command.
551The \-g option changes this behavior to highlight only the particular string
552which was found by the last search command.
553This can cause
554.I less
555to run somewhat faster than the default.
556.IP "\-G or \-\-HILITE-SEARCH"
557The \-G option suppresses all highlighting of strings found by search commands.
558.IP "\-h\fIn\fP or \-\-max-back-scroll=\fIn\fP"
559Specifies a maximum number of lines to scroll backward.
560If it is necessary to scroll backward more than \fIn\fP lines,
561the screen is repainted in a forward direction instead.
562(If the terminal does not have the ability to scroll
563backward, \-h0 is implied.)
564.IP "\-i or \-\-ignore-case"
565Causes searches to ignore case; that is,
566uppercase and lowercase are considered identical.
567This option is ignored if any uppercase letters
568appear in the search pattern;
569in other words,
570if a pattern contains uppercase letters, then that search does not ignore case.
571.IP "\-I or \-\-IGNORE-CASE"
572Like \-i, but searches ignore case even if
573the pattern contains uppercase letters.
574.IP "\-j\fIn\fP or \-\-jump-target=\fIn\fP"
575Specifies a line on the screen where the "target" line
576is to be positioned.
1df93143
PA
577The target line is the line specified by any command to
578search for a pattern, jump to a line number,
579jump to a file percentage or jump to a tag.
131ccf9c
PA
580The screen line may be specified by a number: the top line on the screen
581is 1, the next is 2, and so on.
582The number may be negative to specify a line relative to the bottom
583of the screen: the bottom line on the screen is \-1, the second
584to the bottom is \-2, and so on.
585Alternately, the screen line may be specified as a fraction of the height
586of the screen, starting with a decimal point: .5 is in the middle of the
587screen, .3 is three tenths down from the first line, and so on.
588If the line is specified as a fraction, the actual line number
589is recalculated if the terminal window is resized, so that the
590target line remains at the specified fraction of the screen height.
1df93143
PA
591If any form of the \-j option is used,
592forward searches begin at the line immediately after the target line,
593and backward searches begin at the target line.
131ccf9c 594For example, if "\-j4" is used, the target line is the
1df93143 595fourth line on the screen, so forward searches begin at the fifth line
131ccf9c
PA
596on the screen.
597.IP "\-J or \-\-status-column"
598Displays a status column at the left edge of the screen.
599The status column shows the lines that matched the current search.
600The status column is also used if the \-w or \-W option is in effect.
601.IP "\-k\fIfilename\fP or \-\-lesskey-file=\fIfilename\fP"
602Causes
603.I less
604to open and interpret the named file as a
605.I lesskey
606(1) file.
607Multiple \-k options may be specified.
608If the LESSKEY or LESSKEY_SYSTEM environment variable is set, or
609if a lesskey file is found in a standard place (see KEY BINDINGS),
610it is also used as a
611.I lesskey
612file.
613.IP "\-K or \-\-quit-on-intr"
614Causes
615.I less
616to exit immediately when an interrupt character (usually ^C) is typed.
617Normally, an interrupt character causes
618.I less
619to stop whatever it is doing and return to its command prompt.
1df93143
PA
620Note that use of this option makes it impossible to return to the
621command prompt from the "F" command.
131ccf9c
PA
622.IP "\-L or \-\-no-lessopen"
623Ignore the LESSOPEN environment variable
624(see the INPUT PREPROCESSOR section below).
625This option can be set from within \fIless\fP,
626but it will apply only to files opened subsequently, not to the
627file which is currently open.
628.IP "\-m or \-\-long-prompt"
629Causes
630.I less
631to prompt verbosely (like \fImore\fP),
632with the percent into the file.
633By default,
634.I less
635prompts with a colon.
636.IP "\-M or \-\-LONG-PROMPT"
637Causes
638.I less
639to prompt even more verbosely than
640.I more.
641.IP "\-n or \-\-line-numbers"
642Suppresses line numbers.
643The default (to use line numbers) may cause
644.I less
645to run more slowly in some cases, especially with a very large input file.
646Suppressing line numbers with the \-n option will avoid this problem.
647Using line numbers means: the line number will be displayed in the verbose
648prompt and in the = command,
649and the v command will pass the current line number to the editor
650(see also the discussion of LESSEDIT in PROMPTS below).
651.IP "\-N or \-\-LINE-NUMBERS"
652Causes a line number to be displayed at the beginning of
653each line in the display.
654.IP "\-o\fIfilename\fP or \-\-log-file=\fIfilename\fP"
655Causes
656.I less
657to copy its input to the named file as it is being viewed.
658This applies only when the input file is a pipe,
659not an ordinary file.
660If the file already exists,
661.I less
662will ask for confirmation before overwriting it.
663.IP "\-O\fIfilename\fP or \-\-LOG-FILE=\fIfilename\fP"
664The \-O option is like \-o, but it will overwrite an existing
665file without asking for confirmation.
666.sp
667If no log file has been specified,
668the \-o and \-O options can be used from within
669.I less
670to specify a log file.
671Without a file name, they will simply report the name of the log file.
672The "s" command is equivalent to specifying \-o from within
673.I less.
674.IP "\-p\fIpattern\fP or \-\-pattern=\fIpattern\fP"
675The \-p option on the command line is equivalent to
676specifying +/\fIpattern\fP;
677that is, it tells
678.I less
679to start at the first occurrence of \fIpattern\fP in the file.
680.IP "\-P\fIprompt\fP or \-\-prompt=\fIprompt\fP"
681Provides a way to tailor the three prompt
682styles to your own preference.
683This option would normally be put in the LESS environment
684variable, rather than being typed in with each
685.I less
686command.
687Such an option must either be the last option in the LESS variable,
688or be terminated by a dollar sign.
689-Ps followed by a string changes the default (short) prompt
690to that string.
691-Pm changes the medium (\-m) prompt.
692-PM changes the long (\-M) prompt.
693-Ph changes the prompt for the help screen.
694-P= changes the message printed by the = command.
695-Pw changes the message printed while waiting for data (in the F command).
696All prompt strings consist of a sequence of
697letters and special escape sequences.
698See the section on PROMPTS for more details.
699.IP "\-q or \-\-quiet or \-\-silent"
700Causes moderately "quiet" operation:
701the terminal bell is not rung
702if an attempt is made to scroll past the end of the file
703or before the beginning of the file.
704If the terminal has a "visual bell", it is used instead.
705The bell will be rung on certain other errors,
706such as typing an invalid character.
707The default is to ring the terminal bell in all such cases.
708.IP "\-Q or \-\-QUIET or \-\-SILENT"
709Causes totally "quiet" operation:
710the terminal bell is never rung.
711.IP "\-r or \-\-raw-control-chars"
712Causes "raw" control characters to be displayed.
713The default is to display control characters using the caret notation;
714for example, a control-A (octal 001) is displayed as "^A".
715Warning: when the \-r option is used,
716.I less
717cannot keep track of the actual appearance of the screen
718(since this depends on how the screen responds to
719each type of control character).
720Thus, various display problems may result,
721such as long lines being split in the wrong place.
722.IP "\-R or \-\-RAW-CONTROL-CHARS"
723Like \-r, but only ANSI "color" escape sequences are output in "raw" form.
724Unlike \-r, the screen appearance is maintained correctly in most cases.
725ANSI "color" escape sequences are sequences of the form:
726.sp
727 ESC [ ... m
728.sp
729where the "..." is zero or more color specification characters
730For the purpose of keeping track of screen appearance,
731ANSI color escape sequences are assumed to not move the cursor.
732You can make
733.I less
734think that characters other than "m" can end ANSI color escape sequences
735by setting the environment variable LESSANSIENDCHARS to the list of
736characters which can end a color escape sequence.
737And you can make
738.I less
739think that characters other than the standard ones may appear between
740the ESC and the m by setting the environment variable LESSANSIMIDCHARS
741to the list of characters which can appear.
742.IP "\-s or \-\-squeeze-blank-lines"
743Causes consecutive blank lines to be squeezed into a single blank line.
744This is useful when viewing
745.I nroff
746output.
747.IP "\-S or \-\-chop-long-lines"
748Causes lines longer than the screen width to be
749chopped rather than folded.
750That is, the portion of a long line that does not fit in
751the screen width is not shown.
752The default is to fold long lines; that is, display the remainder
753on the next line.
754.IP "\-t\fItag\fP or \-\-tag=\fItag\fP"
755The \-t option, followed immediately by a TAG,
756will edit the file containing that tag.
757For this to work, tag information must be available;
758for example, there may be a file in the current directory called "tags",
759which was previously built by
760.I ctags
761(1) or an equivalent command.
762If the environment variable LESSGLOBALTAGS is set, it is taken to be
763the name of a command compatible with
764.I global
765(1), and that command is executed to find the tag.
766(See http://www.gnu.org/software/global/global.html).
767The \-t option may also be specified from within
768.I less
769(using the \- command) as a way of examining a new file.
770The command ":t" is equivalent to specifying \-t from within
771.I less.
772.IP "\-T\fItagsfile\fP or \-\-tag-file=\fItagsfile\fP"
773Specifies a tags file to be used instead of "tags".
774.IP "\-u or \-\-underline-special"
775Causes backspaces and carriage returns to be treated as printable characters;
776that is, they are sent to the terminal when they appear in the input.
777.IP "\-U or \-\-UNDERLINE-SPECIAL"
778Causes backspaces, tabs and carriage returns to be
779treated as control characters;
780that is, they are handled as specified by the \-r option.
781.sp
782By default, if neither \-u nor \-U is given,
783backspaces which appear adjacent to an underscore character
784are treated specially:
785the underlined text is displayed
786using the terminal's hardware underlining capability.
787Also, backspaces which appear between two identical characters
788are treated specially:
789the overstruck text is printed
790using the terminal's hardware boldface capability.
791Other backspaces are deleted, along with the preceding character.
792Carriage returns immediately followed by a newline are deleted.
793other carriage returns are handled as specified by the \-r option.
794Text which is overstruck or underlined can be searched for
795if neither \-u nor \-U is in effect.
796.IP "\-V or \-\-version"
797Displays the version number of
798.I less.
799.IP "\-w or \-\-hilite-unread"
800Temporarily highlights the first "new" line after a forward movement
801of a full page.
802The first "new" line is the line immediately following the line previously
803at the bottom of the screen.
804Also highlights the target line after a g or p command.
805The highlight is removed at the next command which causes movement.
806The entire line is highlighted, unless the \-J option is in effect,
807in which case only the status column is highlighted.
808.IP "\-W or \-\-HILITE-UNREAD"
809Like \-w, but temporarily highlights the first new line after any
810forward movement command larger than one line.
811.IP "\-x\fIn\fP,... or \-\-tabs=\fIn\fP,..."
812Sets tab stops.
813If only one \fIn\fP is specified, tab stops are set at multiples of \fIn\fP.
814If multiple values separated by commas are specified, tab stops
815are set at those positions, and then continue with the same spacing as the
816last two.
817For example, \fI-x9,17\fP will set tabs at positions 9, 17, 25, 33, etc.
818The default for \fIn\fP is 8.
819.IP "\-X or \-\-no-init"
820Disables sending the termcap initialization and deinitialization strings
821to the terminal.
822This is sometimes desirable if the deinitialization string does
823something unnecessary, like clearing the screen.
131ccf9c
PA
824.IP "\-y\fIn\fP or \-\-max-forw-scroll=\fIn\fP"
825Specifies a maximum number of lines to scroll forward.
826If it is necessary to scroll forward more than \fIn\fP lines,
827the screen is repainted instead.
828The \-c or \-C option may be used to repaint from the top of
829the screen if desired.
830By default, any forward movement causes scrolling.
831.IP "\-[z]\fIn\fP or \-\-window=\fIn\fP"
832Changes the default scrolling window size to \fIn\fP lines.
833The default is one screenful.
834The z and w commands can also be used to change the window size.
835The "z" may be omitted for compatibility with some versions of
836.I more.
837If the number
838.I n
839is negative, it indicates
840.I n
841lines less than the current screen size.
842For example, if the screen is 24 lines, \fI\-z-4\fP sets the
843scrolling window to 20 lines. If the screen is resized to 40 lines,
844the scrolling window automatically changes to 36 lines.
845.IP "\-\fI\(dqcc\fP\ or\ \-\-quotes=\fIcc\fP"
846Changes the filename quoting character.
847This may be necessary if you are trying to name a file
848which contains both spaces and quote characters.
849Followed by a single character, this changes the quote character to that
850character.
851Filenames containing a space should then be surrounded by that character
852rather than by double quotes.
853Followed by two characters, changes the open quote to the first character,
854and the close quote to the second character.
855Filenames containing a space should then be preceded by the open quote
856character and followed by the close quote character.
857Note that even after the quote characters are changed, this option
858remains \-" (a dash followed by a double quote).
859.IP "\-~ or \-\-tilde"
860Normally lines after end of file are displayed as a single tilde (~).
861This option causes lines after end of file to be displayed as blank lines.
862.IP "\-# or \-\-shift"
863Specifies the default number of positions to scroll horizontally
864in the RIGHTARROW and LEFTARROW commands.
865If the number specified is zero, it sets the default number of
866positions to one half of the screen width.
a9adbba3
JL
867Alternately, the number may be specified as a fraction of the width
868of the screen, starting with a decimal point: .5 is half of the
869screen width, .3 is three tenths of the screen width, and so on.
870If the number is specified as a fraction, the actual number of
871scroll positions is recalculated if the terminal window is resized,
872so that the actual scroll remains at the specified fraction
873of the screen width.
3336a202
PA
874.IP "\-\-no-keypad"
875Disables sending the keypad initialization and deinitialization strings
876to the terminal.
877This is sometimes useful if the keypad strings make the numeric
878keypad behave in an undesirable manner.
879.IP "\-\-follow-name"
880Normally, if the input file is renamed while an F command is executing,
881.I less
882will continue to display the contents of the original file despite
883its name change.
884If \-\-follow-name is specified, during an F command
885.I less
886will periodically attempt to reopen the file by name.
887If the reopen succeeds and the file is a different file from the original
888(which means that a new file has been created
889with the same name as the original (now renamed) file),
890.I less
891will display the contents of that new file.
131ccf9c
PA
892.IP \-\-
893A command line argument of "\-\-" marks the end of option arguments.
894Any arguments following this are interpreted as filenames.
895This can be useful when viewing a file whose name begins with a "\-" or "+".
896.IP +
897If a command line option begins with \fB+\fP,
898the remainder of that option is taken to be an initial command to
899.I less.
900For example, +G tells
901.I less
902to start at the end of the file rather than the beginning,
903and +/xyz tells it to start at the first occurrence of "xyz" in the file.
904As a special case, +<number> acts like +<number>g;
905that is, it starts the display at the specified line number
906(however, see the caveat under the "g" command above).
907If the option starts with ++, the initial command applies to
908every file being viewed, not just the first one.
909The + command described previously
910may also be used to set (or change) an initial command for every file.
911
912.SH "LINE EDITING"
913When entering command line at the bottom of the screen
914(for example, a filename for the :e command,
915or the pattern for a search command),
916certain keys can be used to manipulate the command line.
917Most commands have an alternate form in [ brackets ] which can be used if
918a key does not exist on a particular keyboard.
67a79ec0
PA
919(Note that the forms beginning with ESC do not work
920in some MS-DOS and Windows systems because ESC is the line erase character.)
131ccf9c
PA
921Any of these special keys may be entered literally by preceding
922it with the "literal" character, either ^V or ^A.
923A backslash itself may also be entered literally by entering two backslashes.
924.IP "LEFTARROW [ ESC-h ]"
925Move the cursor one space to the left.
926.IP "RIGHTARROW [ ESC-l ]"
927Move the cursor one space to the right.
928.IP "^LEFTARROW [ ESC-b or ESC-LEFTARROW ]"
929(That is, CONTROL and LEFTARROW simultaneously.)
930Move the cursor one word to the left.
931.IP "^RIGHTARROW [ ESC-w or ESC-RIGHTARROW ]"
932(That is, CONTROL and RIGHTARROW simultaneously.)
933Move the cursor one word to the right.
934.IP "HOME [ ESC-0 ]"
935Move the cursor to the beginning of the line.
936.IP "END [ ESC-$ ]"
937Move the cursor to the end of the line.
938.IP "BACKSPACE"
939Delete the character to the left of the cursor,
940or cancel the command if the command line is empty.
941.IP "DELETE or [ ESC-x ]"
942Delete the character under the cursor.
943.IP "^BACKSPACE [ ESC-BACKSPACE ]"
944(That is, CONTROL and BACKSPACE simultaneously.)
945Delete the word to the left of the cursor.
946.IP "^DELETE [ ESC-X or ESC-DELETE ]"
947(That is, CONTROL and DELETE simultaneously.)
948Delete the word under the cursor.
949.IP "UPARROW [ ESC-k ]"
950Retrieve the previous command line.
951.IP "DOWNARROW [ ESC-j ]"
952Retrieve the next command line.
953.IP "TAB"
954Complete the partial filename to the left of the cursor.
955If it matches more than one filename, the first match
956is entered into the command line.
957Repeated TABs will cycle thru the other matching filenames.
958If the completed filename is a directory, a "/" is appended to the filename.
959(On MS-DOS systems, a "\e" is appended.)
960The environment variable LESSSEPARATOR can be used to specify a
961different character to append to a directory name.
962.IP "BACKTAB [ ESC-TAB ]"
963Like, TAB, but cycles in the reverse direction thru the matching filenames.
964.IP "^L"
965Complete the partial filename to the left of the cursor.
966If it matches more than one filename, all matches are entered into
967the command line (if they fit).
968.IP "^U (Unix and OS/2) or ESC (MS-DOS)"
969Delete the entire command line,
970or cancel the command if the command line is empty.
971If you have changed your line-kill character in Unix to something
972other than ^U, that character is used instead of ^U.
973
974.SH "KEY BINDINGS"
975You may define your own
976.I less
977commands by using the program
978.I lesskey
979(1)
980to create a lesskey file.
981This file specifies a set of command keys and an action
982associated with each key.
983You may also use
984.I lesskey
985to change the line-editing keys (see LINE EDITING),
986and to set environment variables.
987If the environment variable LESSKEY is set,
988.I less
989uses that as the name of the lesskey file.
990Otherwise,
991.I less
992looks in a standard place for the lesskey file:
993On Unix systems,
994.I less
995looks for a lesskey file called "$HOME/.less".
996On MS-DOS and Windows systems,
997.I less
998looks for a lesskey file called "$HOME/_less", and if it is not found there,
999then looks for a lesskey file called "_less" in any directory specified
1000in the PATH environment variable.
1001On OS/2 systems,
1002.I less
1003looks for a lesskey file called "$HOME/less.ini", and if it is not found,
1004then looks for a lesskey file called "less.ini" in any directory specified
1005in the INIT environment variable, and if it not found there,
1006then looks for a lesskey file called "less.ini" in any directory specified
1007in the PATH environment variable.
1008See the
1009.I lesskey
1010manual page for more details.
1011.P
1012A system-wide lesskey file may also be set up to provide key bindings.
1013If a key is defined in both a local lesskey file and in the
1014system-wide file, key bindings in the local file take precedence over
1015those in the system-wide file.
1016If the environment variable LESSKEY_SYSTEM is set,
1017.I less
1018uses that as the name of the system-wide lesskey file.
1019Otherwise,
1020.I less
1021looks in a standard place for the system-wide lesskey file:
1022On Unix systems, the system-wide lesskey file is /usr/local/etc/sysless.
1023(However, if
1024.I less
1025was built with a different sysconf directory than /usr/local/etc,
1026that directory is where the sysless file is found.)
1027On MS-DOS and Windows systems, the system-wide lesskey file is c:\e_sysless.
1028On OS/2 systems, the system-wide lesskey file is c:\esysless.ini.
1029
1030.SH "INPUT PREPROCESSOR"
1031You may define an "input preprocessor" for
1032.I less.
1033Before
1034.I less
1035opens a file, it first gives your input preprocessor a chance to modify the
1036way the contents of the file are displayed.
1037An input preprocessor is simply an executable program (or shell script),
1038which writes the contents of the file to a different file,
1039called the replacement file.
1040The contents of the replacement file are then displayed
1041in place of the contents of the original file.
1042However, it will appear to the user as if the original file is opened;
1043that is,
1044.I less
1045will display the original filename as the name of the current file.
1046.PP
1047An input preprocessor receives one command line argument, the original filename,
1048as entered by the user.
1049It should create the replacement file, and when finished,
1050print the name of the replacement file to its standard output.
1051If the input preprocessor does not output a replacement filename,
1052.I less
1053uses the original file, as normal.
1054The input preprocessor is not called when viewing standard input.
1055To set up an input preprocessor, set the LESSOPEN environment variable
1056to a command line which will invoke your input preprocessor.
1057This command line should include one occurrence of the string "%s",
1058which will be replaced by the filename
1059when the input preprocessor command is invoked.
1060.PP
1061When
1062.I less
1063closes a file opened in such a way, it will call another program,
1064called the input postprocessor,
1065which may perform any desired clean-up action (such as deleting the
1066replacement file created by LESSOPEN).
1067This program receives two command line arguments, the original filename
1068as entered by the user, and the name of the replacement file.
1069To set up an input postprocessor, set the LESSCLOSE environment variable
1070to a command line which will invoke your input postprocessor.
1071It may include two occurrences of the string "%s";
1072the first is replaced with the original name of the file and
1073the second with the name of the replacement file,
1074which was output by LESSOPEN.
1075.PP
1076For example, on many Unix systems, these two scripts will allow you
1077to keep files in compressed format, but still let
1078.I less
1079view them directly:
1080.PP
1081lessopen.sh:
1082.br
1083 #! /bin/sh
1084.br
1085 case "$1" in
1086.br
1087 *.Z) uncompress -\c $1 >/tmp/less.$$ 2>/dev/null
1088.br
1089 if [ \-s /tmp/less.$$ ]; then
1090.br
1091 echo /tmp/less.$$
1092.br
1093 else
1094.br
1095 rm \-f /tmp/less.$$
1096.br
1097 fi
1098.br
1099 ;;
1100.br
1101 esac
1102.PP
1103lessclose.sh:
1104.br
1105 #! /bin/sh
1106.br
1107 rm $2
1108.PP
1109To use these scripts, put them both where they can be executed and
1110set LESSOPEN="lessopen.sh\ %s", and
1111LESSCLOSE="lessclose.sh\ %s\ %s".
1112More complex LESSOPEN and LESSCLOSE scripts may be written
1113to accept other types of compressed files, and so on.
1114.PP
1115It is also possible to set up an input preprocessor to
1116pipe the file data directly to
1117.I less,
1118rather than putting the data into a replacement file.
1119This avoids the need to decompress the entire file before
1120starting to view it.
1121An input preprocessor that works this way is called an input pipe.
1122An input pipe, instead of writing the name of a replacement file on
1123its standard output,
1124writes the entire contents of the replacement file on its standard output.
1125If the input pipe does not write any characters on its standard output,
1126then there is no replacement file and
1127.I less
1128uses the original file, as normal.
1129To use an input pipe,
1130make the first character in the LESSOPEN environment variable a
1131vertical bar (|) to signify that the input preprocessor is an input pipe.
1132.PP
1133For example, on many Unix systems, this script will work like the
1134previous example scripts:
1135.PP
1136lesspipe.sh:
1137.br
1138 #! /bin/sh
1139.br
1140 case "$1" in
1141.br
1142 *.Z) uncompress \-c $1 2>/dev/null
1143.br
1144 ;;
1145.br
1146 esac
1147.br
1148.PP
1149To use this script, put it where it can be executed and set
1150LESSOPEN="|lesspipe.sh %s".
1151When an input pipe is used, a LESSCLOSE postprocessor can be used,
1152but it is usually not necessary since there is no replacement file
1153to clean up.
1154In this case, the replacement file name passed to the LESSCLOSE
1155postprocessor is "\-".
8be36e5b
PA
1156.PP
1157For compatibility with previous versions of
1158.I less,
a9adbba3 1159the input preprocessor or pipe is not used if
8be36e5b
PA
1160.I less
1161is viewing standard input.
a9adbba3
JL
1162However, if the first character of LESSOPEN is a dash (\-),
1163the input preprocessor is used on standard input as well as other files.
1164In this case, the dash is not considered to be part of
1165the preprocessor command.
1166If standard input is being viewed, the input preprocessor is passed
1167a file name consisting of a single dash.
1168Similarly, if the first two characters of LESSOPEN are vertical bar and dash
1169(|\-), the input pipe is used on standard input as well as other files.
1170Again, in this case the dash is not considered to be part of
1171the input pipe command.
131ccf9c
PA
1172
1173.SH "NATIONAL CHARACTER SETS"
1174There are three types of characters in the input file:
1175.IP "normal characters"
1176can be displayed directly to the screen.
1177.IP "control characters"
1178should not be displayed directly, but are expected to be found
1179in ordinary text files (such as backspace and tab).
1180.IP "binary characters"
1181should not be displayed directly and are not expected to be found
1182in text files.
1183.PP
1184A "character set" is simply a description of which characters are to
1185be considered normal, control, and binary.
1186The LESSCHARSET environment variable may be used to select a character set.
1187Possible values for LESSCHARSET are:
1188.IP ascii
1189BS, TAB, NL, CR, and formfeed are control characters,
1190all chars with values between 32 and 126 are normal,
1191and all others are binary.
1192.IP iso8859
1193Selects an ISO 8859 character set.
1194This is the same as ASCII, except characters between 160 and 255 are
1195treated as normal characters.
1196.IP latin1
1197Same as iso8859.
1198.IP latin9
1199Same as iso8859.
1200.IP dos
1201Selects a character set appropriate for MS-DOS.
1202.IP ebcdic
1203Selects an EBCDIC character set.
1204.IP IBM-1047
1205Selects an EBCDIC character set used by OS/390 Unix Services.
1206This is the EBCDIC analogue of latin1. You get similar results
1207by setting either LESSCHARSET=IBM-1047 or LC_CTYPE=en_US
1208in your environment.
1209.IP koi8-r
1210Selects a Russian character set.
1211.IP next
1212Selects a character set appropriate for NeXT computers.
1213.IP utf-8
1214Selects the UTF-8 encoding of the ISO 10646 character set.
1215UTF-8 is special in that it supports multi-byte characters in the input file.
1216It is the only character set that supports multi-byte characters.
1217.IP windows
1218Selects a character set appropriate for Microsoft Windows (cp 1251).
1219.PP
67a79ec0 1220In rare cases, it may be desired to tailor
131ccf9c
PA
1221.I less
1222to use a character set other than the ones definable by LESSCHARSET.
1223In this case, the environment variable LESSCHARDEF can be used
1224to define a character set.
1225It should be set to a string where each character in the string represents
1226one character in the character set.
1227The character "." is used for a normal character, "c" for control,
1228and "b" for binary.
1229A decimal number may be used for repetition.
1230For example, "bccc4b." would mean character 0 is binary,
12311, 2 and 3 are control, 4, 5, 6 and 7 are binary, and 8 is normal.
1232All characters after the last are taken to be the same as the last,
1233so characters 9 through 255 would be normal.
1234(This is an example, and does not necessarily
1235represent any real character set.)
1236.PP
1237This table shows the value of LESSCHARDEF which is equivalent
1238to each of the possible values for LESSCHARSET:
1239.sp
1240 ascii\ 8bcccbcc18b95.b
1241.br
1242 dos\ \ \ 8bcccbcc12bc5b95.b.
1243.br
1244 ebcdic 5bc6bcc7bcc41b.9b7.9b5.b..8b6.10b6.b9.7b
1245.br
1246 \ \ \ \ \ \ 9.8b8.17b3.3b9.7b9.8b8.6b10.b.b.b.
1247.br
1248 IBM-1047 4cbcbc3b9cbccbccbb4c6bcc5b3cbbc4bc4bccbc
1249.br
1250 \ \ \ \ \ \ 191.b
1251.br
1252 iso8859 8bcccbcc18b95.33b.
1253.br
1254 koi8-r 8bcccbcc18b95.b128.
1255.br
1256 latin1 8bcccbcc18b95.33b.
1257.br
1258 next\ \ 8bcccbcc18b95.bb125.bb
1259.PP
1260If neither LESSCHARSET nor LESSCHARDEF is set,
1261but any of the strings "UTF-8", "UTF8", "utf-8" or "utf8"
1262is found in the LC_ALL, LC_TYPE or LANG
1263environment variables, then the default character set is utf-8.
1264.PP
1265If that string is not found, but your system supports the
1266.I setlocale
1267interface,
1268.I less
1269will use setlocale to determine the character set.
1270setlocale is controlled by setting the LANG or LC_CTYPE environment
1271variables.
1272.PP
1273Finally, if the
1274.I setlocale
1275interface is also not available, the default character set is latin1.
1276.PP
1277Control and binary characters are displayed in standout (reverse video).
1278Each such character is displayed in caret notation if possible
1279(e.g. ^A for control-A). Caret notation is used only if
1280inverting the 0100 bit results in a normal printable character.
1281Otherwise, the character is displayed as a hex number in angle brackets.
1282This format can be changed by
1283setting the LESSBINFMT environment variable.
1284LESSBINFMT may begin with a "*" and one character to select
1285the display attribute:
1286"*k" is blinking, "*d" is bold, "*u" is underlined, "*s" is standout,
1287and "*n" is normal.
1288If LESSBINFMT does not begin with a "*", normal attribute is assumed.
1289The remainder of LESSBINFMT is a string which may include one
1290printf-style escape sequence (a % followed by x, X, o, d, etc.).
1291For example, if LESSBINFMT is "*u[%x]", binary characters
1292are displayed in underlined hexadecimal surrounded by brackets.
1293The default if no LESSBINFMT is specified is "*s<%X>".
1294The default if no LESSBINFMT is specified is "*s<%02X>".
1295Warning: the result of expanding the character via LESSBINFMT must
1296be less than 31 characters.
1297.PP
1298When the character set is utf-8, the LESSUTFBINFMT environment variable
1299acts similarly to LESSBINFMT but it applies to Unicode code points
1300that were successfully decoded but are unsuitable for display (e.g.,
1301unassigned code points).
1302Its default value is "<U+%04lX>".
1303Note that LESSUTFBINFMT and LESSBINFMT share their display attribute
1304setting ("*x") so specifying one will affect both;
1305LESSUTFBINFMT is read after LESSBINFMT so its setting, if any,
1306will have priority.
1307Problematic octets in a UTF-8 file (octets of a truncated sequence,
1308octets of a complete but non-shortest form sequence, illegal octets,
1309and stray trailing octets)
1310are displayed individually using LESSBINFMT so as to facilitate diagnostic
1311of how the UTF-8 file is ill-formed.
1312
1313.SH "PROMPTS"
1314The \-P option allows you to tailor the prompt to your preference.
1315The string given to the \-P option replaces the specified prompt string.
1316Certain characters in the string are interpreted specially.
1317The prompt mechanism is rather complicated to provide flexibility,
1318but the ordinary user need not understand the details of constructing
1319personalized prompt strings.
1320.sp
1321A percent sign followed by a single character is expanded
1322according to what the following character is:
1323.IP "%b\fIX\fP"
1324Replaced by the byte offset into the current input file.
1325The b is followed by a single character (shown as \fIX\fP above)
1326which specifies the line whose byte offset is to be used.
1327If the character is a "t", the byte offset of the top line in the
1328display is used,
1329an "m" means use the middle line,
1330a "b" means use the bottom line,
1331a "B" means use the line just after the bottom line,
1332and a "j" means use the "target" line, as specified by the \-j option.
1333.IP "%B"
1334Replaced by the size of the current input file.
1335.IP "%c"
1336Replaced by the column number of the text appearing in the first
1337column of the screen.
1338.IP "%d\fIX\fP"
1339Replaced by the page number of a line in the input file.
1340The line to be used is determined by the \fIX\fP, as with the %b option.
1341.IP "%D"
1342Replaced by the number of pages in the input file,
1343or equivalently, the page number of the last line in the input file.
1344.IP "%E"
1345Replaced by the name of the editor (from the VISUAL environment variable,
1346or the EDITOR environment variable if VISUAL is not defined).
1347See the discussion of the LESSEDIT feature below.
1348.IP "%f"
1349Replaced by the name of the current input file.
1350.IP "%i"
1351Replaced by the index of the current file in the list of
1352input files.
1353.IP "%l\fIX\fP"
1354Replaced by the line number of a line in the input file.
1355The line to be used is determined by the \fIX\fP, as with the %b option.
1356.IP "%L"
1357Replaced by the line number of the last line in the input file.
1358.IP "%m"
1359Replaced by the total number of input files.
1360.IP "%p\fIX\fP"
1361Replaced by the percent into the current input file, based on byte offsets.
1362The line used is determined by the \fIX\fP as with the %b option.
1363.IP "%P\fIX\fP"
1364Replaced by the percent into the current input file, based on line numbers.
1365The line used is determined by the \fIX\fP as with the %b option.
1366.IP "%s"
1367Same as %B.
1368.IP "%t"
1369Causes any trailing spaces to be removed.
1370Usually used at the end of the string, but may appear anywhere.
1371.IP "%x"
1372Replaced by the name of the next input file in the list.
1373.PP
1374If any item is unknown (for example, the file size if input
1375is a pipe), a question mark is printed instead.
1376.PP
1377The format of the prompt string can be changed
1378depending on certain conditions.
1379A question mark followed by a single character acts like an "IF":
1380depending on the following character, a condition is evaluated.
1381If the condition is true, any characters following the question mark
1382and condition character, up to a period, are included in the prompt.
1383If the condition is false, such characters are not included.
1384A colon appearing between the question mark and the
1385period can be used to establish an "ELSE": any characters between
1386the colon and the period are included in the string if and only if
1387the IF condition is false.
1388Condition characters (which follow a question mark) may be:
1389.IP "?a"
1390True if any characters have been included in the prompt so far.
1391.IP "?b\fIX\fP"
1392True if the byte offset of the specified line is known.
1393.IP "?B"
1394True if the size of current input file is known.
1395.IP "?c"
1396True if the text is horizontally shifted (%c is not zero).
1397.IP "?d\fIX\fP"
1398True if the page number of the specified line is known.
1399.IP "?e"
1400True if at end-of-file.
1401.IP "?f"
1402True if there is an input filename
1403(that is, if input is not a pipe).
1404.IP "?l\fIX\fP"
1405True if the line number of the specified line is known.
1406.IP "?L"
1407True if the line number of the last line in the file is known.
1408.IP "?m"
1409True if there is more than one input file.
1410.IP "?n"
1411True if this is the first prompt in a new input file.
1412.IP "?p\fIX\fP"
1413True if the percent into the current input file, based on byte offsets,
1414of the specified line is known.
1415.IP "?P\fIX\fP"
1416True if the percent into the current input file, based on line numbers,
1417of the specified line is known.
1418.IP "?s"
1419Same as "?B".
1420.IP "?x"
1421True if there is a next input file
1422(that is, if the current input file is not the last one).
1423.PP
1424Any characters other than the special ones
1425(question mark, colon, period, percent, and backslash)
1426become literally part of the prompt.
1427Any of the special characters may be included in the prompt literally
1428by preceding it with a backslash.
1429.PP
1430Some examples:
1431.sp
1432?f%f:Standard input.
1433.sp
1434This prompt prints the filename, if known;
1435otherwise the string "Standard input".
1436.sp
1437?f%f .?ltLine %lt:?pt%pt\e%:?btByte %bt:-...
1438.sp
1439This prompt would print the filename, if known.
1440The filename is followed by the line number, if known,
1441otherwise the percent if known, otherwise the byte offset if known.
1442Otherwise, a dash is printed.
1443Notice how each question mark has a matching period,
1444and how the % after the %pt
1445is included literally by escaping it with a backslash.
1446.sp
1447?n?f%f\ .?m(file\ %i\ of\ %m)\ ..?e(END)\ ?x-\ Next\e:\ %x..%t
1448.sp
1449This prints the filename if this is the first prompt in a file,
1450followed by the "file N of N" message if there is more
1451than one input file.
1452Then, if we are at end-of-file, the string "(END)" is printed
1453followed by the name of the next file, if there is one.
1454Finally, any trailing spaces are truncated.
1455This is the default prompt.
1456For reference, here are the defaults for
1457the other two prompts (\-m and \-M respectively).
1458Each is broken into two lines here for readability only.
1459.nf
1460.sp
1461?n?f%f\ .?m(file\ %i\ of\ %m)\ ..?e(END)\ ?x-\ Next\e:\ %x.:
1462 ?pB%pB\e%:byte\ %bB?s/%s...%t
1463.sp
1464?f%f\ .?n?m(file\ %i\ of\ %m)\ ..?ltlines\ %lt-%lb?L/%L.\ :
1465 byte\ %bB?s/%s.\ .?e(END)\ ?x-\ Next\e:\ %x.:?pB%pB\e%..%t
1466.sp
1467.fi
1468And here is the default message produced by the = command:
1469.nf
1470.sp
1471?f%f\ .?m(file\ %i\ of\ %m)\ .?ltlines\ %lt-%lb?L/%L.\ .
1472 byte\ %bB?s/%s.\ ?e(END)\ :?pB%pB\e%..%t
1473.fi
1474.PP
1475The prompt expansion features are also used for another purpose:
1476if an environment variable LESSEDIT is defined, it is used
1477as the command to be executed when the v command is invoked.
1478The LESSEDIT string is expanded in the same way as the prompt strings.
1479The default value for LESSEDIT is:
1480.nf
1481.sp
1482 %E\ ?lm+%lm.\ %f
1483.sp
1484.fi
1485Note that this expands to the editor name, followed by a + and the
1486line number, followed by the file name.
1487If your editor does not accept the "+linenumber" syntax, or has other
1488differences in invocation syntax, the LESSEDIT variable can be
1489changed to modify this default.
1490
1491.SH SECURITY
1492When the environment variable LESSSECURE is set to 1,
1493.I less
1494runs in a "secure" mode.
1495This means these features are disabled:
1496.RS
1497.IP "!"
1498the shell command
1499.IP "|"
1500the pipe command
1501.IP ":e"
1502the examine command.
1503.IP "v"
1504the editing command
1505.IP "s \-o"
1506log files
1507.IP "\-k"
1508use of lesskey files
1509.IP "\-t"
1510use of tags files
1511.IP " "
1512metacharacters in filenames, such as *
1513.IP " "
1514filename completion (TAB, ^L)
1515.RE
1516.PP
1517Less can also be compiled to be permanently in "secure" mode.
1518
1519.SH "COMPATIBILITY WITH MORE"
1520If the environment variable LESS_IS_MORE is set to 1,
1521or if the program is invoked via a file link named "more",
1522.I less
1523behaves (mostly) in conformance with the POSIX "more" command specification.
1524In this mode, less behaves differently in these ways:
1525.PP
1526The \-e option works differently.
1527If the \-e option is not set,
1528.I less
1529behaves as if the \-E option were set.
1530If the \-e option is set,
1531.I less
1532behaves as if the \-e and \-F options were set.
1533.PP
1534The \-m option works differently.
1535If the \-m option is not set, the medium prompt is used,
1536and it is prefixed with the string "--More--".
1537If the \-m option is set, the short prompt is used.
1538.PP
1539The \-n option acts like the \-z option.
1540The normal behavior of the \-n option is unavailable in this mode.
1541.PP
1542The parameter to the \-p option is taken to be a
1543.I less
1544command rather than a search pattern.
1545.PP
1546The LESS environment variable is ignored,
1547and the MORE environment variable is used in its place.
1548
1549.SH "ENVIRONMENT VARIABLES"
1550Environment variables may be specified either in the system environment
1551as usual, or in a
1552.I lesskey
1553(1) file.
1554If environment variables are defined in more than one place,
1555variables defined in a local lesskey file take precedence over
1556variables defined in the system environment, which take precedence
1557over variables defined in the system-wide lesskey file.
1558.IP COLUMNS
1559Sets the number of columns on the screen.
1560Takes precedence over the number of columns specified by the TERM variable.
1561(But if you have a windowing system which supports TIOCGWINSZ or WIOCGETD,
1562the window system's idea of the screen size takes precedence over the
1563LINES and COLUMNS environment variables.)
1564.IP EDITOR
1565The name of the editor (used for the v command).
1566.IP HOME
1567Name of the user's home directory
1568(used to find a lesskey file on Unix and OS/2 systems).
1569.IP "HOMEDRIVE, HOMEPATH"
1570Concatenation of the HOMEDRIVE and HOMEPATH environment variables is
1571the name of the user's home directory if the HOME variable is not set
1572(only in the Windows version).
1573.IP INIT
1574Name of the user's init directory (used to find a lesskey file on OS/2 systems).
1575.IP LANG
1576Language for determining the character set.
1577.IP LC_CTYPE
1578Language for determining the character set.
1579.IP LESS
1580Options which are passed to
1581.I less
1582automatically.
1583.IP LESSANSIENDCHARS
1584Characters which may end an ANSI color escape sequence
1585(default "m").
1586.IP LESSANSIMIDCHARS
1587Characters which may appear between the ESC character and the
1588end character in an ANSI color escape sequence
1589(default "0123456789;[?!"'#%()*+\ ".
1590.IP LESSBINFMT
1591Format for displaying non-printable, non-control characters.
1592.IP LESSCHARDEF
1593Defines a character set.
1594.IP LESSCHARSET
1595Selects a predefined character set.
1596.IP LESSCLOSE
1597Command line to invoke the (optional) input-postprocessor.
1598.IP LESSECHO
1599Name of the lessecho program (default "lessecho").
1600The lessecho program is needed to expand metacharacters, such as * and ?,
1601in filenames on Unix systems.
1602.IP LESSEDIT
1603Editor prototype string (used for the v command).
1604See discussion under PROMPTS.
1605.IP LESSGLOBALTAGS
1606Name of the command used by the \-t option to find global tags.
1607Normally should be set to "global" if your system has the
1608.I global
1609(1) command. If not set, global tags are not used.
1610.IP LESSHISTFILE
1611Name of the history file used to remember search commands and
1612shell commands between invocations of
1613.I less.
1614If set to "\-" or "/dev/null", a history file is not used.
1615The default is "$HOME/.lesshst" on Unix systems, "$HOME/_lesshst" on
1616DOS and Windows systems, or "$HOME/lesshst.ini" or "$INIT/lesshst.ini"
1617on OS/2 systems.
1618.IP LESSHISTSIZE
1619The maximum number of commands to save in the history file.
1620The default is 100.
1621.IP LESSKEY
1622Name of the default lesskey(1) file.
1623.IP LESSKEY_SYSTEM
1624Name of the default system-wide lesskey(1) file.
1625.IP LESSMETACHARS
1626List of characters which are considered "metacharacters" by the shell.
1627.IP LESSMETAESCAPE
1628Prefix which less will add before each metacharacter in a
1629command sent to the shell.
1630If LESSMETAESCAPE is an empty string, commands containing
1631metacharacters will not be passed to the shell.
1632.IP LESSOPEN
1633Command line to invoke the (optional) input-preprocessor.
1634.IP LESSSECURE
1635Runs less in "secure" mode.
1636See discussion under SECURITY.
1637.IP LESSSEPARATOR
1638String to be appended to a directory name in filename completion.
1639.IP LESSUTFBINFMT
1640Format for displaying non-printable Unicode code points.
1641.IP LESS_IS_MORE
1642Emulate the
1643.I more
1644(1) command.
1645.IP LINES
1646Sets the number of lines on the screen.
1647Takes precedence over the number of lines specified by the TERM variable.
1648(But if you have a windowing system which supports TIOCGWINSZ or WIOCGETD,
1649the window system's idea of the screen size takes precedence over the
1650LINES and COLUMNS environment variables.)
1651.IP PATH
1652User's search path (used to find a lesskey file
1653on MS-DOS and OS/2 systems).
1654.IP SHELL
1655The shell used to execute the ! command, as well as to expand filenames.
1656.IP TERM
1657The type of terminal on which
1658.I less
1659is being run.
1660.IP VISUAL
1661The name of the editor (used for the v command).
1662
1663.SH "SEE ALSO"
1664lesskey(1)
1665
131ccf9c 1666.SH COPYRIGHT
a9adbba3 1667Copyright (C) 1984-2009 Mark Nudelman
131ccf9c
PA
1668.PP
1669less is part of the GNU project and is free software.
1670You can redistribute it and/or modify it
1671under the terms of either
1672(1) the GNU General Public License as published by
1673the Free Software Foundation; or (2) the Less License.
1674See the file README in the less distribution for more details
1675regarding redistribution.
1676You should have received a copy of the GNU General Public License
1677along with the source for less; see the file COPYING.
1678If not, write to the Free Software Foundation, 59 Temple Place,
1679Suite 330, Boston, MA 02111-1307, USA.
1680You should also have received a copy of the Less License;
1681see the file LICENSE.
1682.PP
1683less is distributed in the hope that it will be useful, but
1684WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
1685or FITNESS FOR A PARTICULAR PURPOSE.
1686See the GNU General Public License for more details.
1687
1688.SH AUTHOR
1689.PP
1690Mark Nudelman <markn@greenwoodsoftware.com>
1691.br
67a79ec0
PA
1692See http://www.greenwoodsoftware.com/less/bugs.html for the latest list of known bugs in less.
1693.br
131ccf9c
PA
1694Send bug reports or comments to the above address or to
1695.br
1696bug-less@gnu.org.
1697.br
1698For more information, see the less homepage at
1699.br
1700http://www.greenwoodsoftware.com/less.