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