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