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