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