Annotation of src/usr.bin/less/less.1, Revision 1.2
1.2 ! jmc 1: .\" $OpenBSD: less.1,v 1.1 2003/04/16 17:54:20 millert Exp $
1.1 millert 2: .\"
3: .\" Copyright (C) 2002 Mark Nudelman
4: .\"
5: .\" less is part of the GNU project and is free software.
6: .\" You can redistribute it and/or modify it
7: .\" under the terms of either
8: .\" (1) the GNU General Public License as published by
9: .\" the Free Software Foundation; or (2) the Less License.
10: .\" See the file README in the less distribution for more details
11: .\" regarding redistribution.
12: .\" You should have received a copy of the GNU General Public License
13: .\" along with the source for less; see the file COPYING.
14: .\" If not, write to the Free Software Foundation, 59 Temple Place,
15: .\" Suite 330, Boston, MA 02111-1307, USA.
16: .\" You should also have received a copy of the Less License;
17: .\" see the file LICENSE.
18: .\"
19: .\" less is distributed in the hope that it will be useful, but
20: .\" WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21: .\" or FITNESS FOR A PARTICULAR PURPOSE.
22: .\" See the GNU General Public License for more details.
23: .\"
24: .\"
25: .Dd January 17, 2003
26: .Dt LESS 1
27: .Os
28: .Sh NAME
29: .Nm less , more
30: .Nd view files on a crt
31: .Sh SYNOPSIS
32: .Nm less No | Nm more
33: .Fl ?
34: .Nm less No | Nm more
35: .Fl -help
36: .Nm less No | Nm more
37: .Fl V
38: .Nm less No | Nm more
39: .Fl -version
40: .Nm less No | Nm more
41: .Bk -words
42: .Op Fl Oo Cm + Oc Ns Cm aBcCdeEfFgGiIJLmMnNqQrRsSuUVwWX~
43: .Op Fl b Ar space
44: .Op Fl h Ar lines
45: .Op Fl j Ar line
46: .Op Fl k Ar keyfile
47: .Op Fl o | O Ar logfile
48: .Op Fl p Ar pattern
49: .Op Fl P Ar prompt
50: .Op Fl t Ar tag
51: .Op Fl T Ar tagsfile
52: .Op Fl x Ar tab,...
53: .Op Fl y Ar lines
54: .Op Fl Oo Cm z Oc Ar \ \&lines
55: .Op Fl # Ar shift
56: .Xo Oo Cm \+ Ns Oo Ns Cm \+ Ns
57: .Oc Ar cmd
58: .Oc
59: .Xc
60: .Op Fl -
61: .Op Ar filename ...
62: .Ek
63: .Pp
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
233: .It Ic ^N | !
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
258: .It Ic ^N | !
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.
438: .It Ic ! Ar shell-command
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: .Pp
517: .Bl -tag -width XXXX
518: .It Fl ? | -help
519: This option displays a summary of the commands accepted by
520: .Nm
521: (the same as the h command).
522: (Depending on how your shell interprets the question mark,
523: it may be necessary to quote the question mark, thus: "-\e?".)
524: .It Fl a | -search-skip-screen
525: Causes searches to start after the last line displayed on the screen,
526: thus skipping all lines displayed on the screen.
527: By default, searches start at the second line on the screen
528: (or after the last found line; see the -j option).
529: .It Xo
530: .Fl b Ns Ar n |
531: .Fl -buffers Ns No = Ns Ar n
532: .Xc
533: Specifies the amount of buffer space
534: .Nm
535: will use for each file, in units of kilobytes (1024 bytes).
536: By default 64K of buffer space is used for each file
537: (unless the file is a pipe; see the -B option).
538: The -b option specifies instead that n kilobytes of
539: buffer space should be used for each file.
540: If n is -1, buffer space is unlimited; that is,
541: the entire file is read into memory.
542: .It Fl B | -auto-buffers
543: By default, when data is read from a pipe,
544: buffers are allocated automatically as needed.
545: If a large amount of data is read from the pipe, this can cause
546: a large amount of memory to be allocated.
547: The -B option disables this automatic allocation of buffers for pipes,
548: so that only 64K (or the amount of space specified by the -b option)
549: is used for the pipe.
550: Warning: use of -B can result in erroneous display, since only the
551: most recently viewed part of the file is kept in memory;
552: any earlier data is lost.
553: .It Fl c | -clear-screen
554: Causes full screen repaints to be painted from the top line down.
555: By default,
556: full screen repaints are done by scrolling from the bottom of the screen.
557: .It Fl C | -CLEAR-SCREEN
558: The -C option is like -c, but the screen is cleared before it is repainted.
559: .It Fl d | -dumb No (less only)
560: The -d option suppresses the error message
561: normally displayed if the terminal is dumb;
562: that is, lacks some important capability,
563: such as the ability to clear the screen or scroll backward.
564: The -d option does not otherwise change the behavior of
565: .Nm
566: on a dumb terminal.
567: This option is on by default when invoked as
568: .Nm more .
569: .It Fl d No (more only)
570: The -d option causes the default prompt to include the
571: basic directions ``[Press space to continue, 'q' to quit.]''.
572: The -d option also causes the message ``[Press 'h' for instructions.]'' to be
573: displayed when an invalid command is entered (normally, the bell is rung).
574: This option is useful in environments where users may not be experienced
575: with pagers.
576: .\" .It Fl Dxcolor or --color=xcolor"
577: .\" [MS-DOS only]
578: .\" Sets the color of the text displayed.
579: .\" x is a single character which selects the type of text whose color is
580: .\" being set: n=normal, s=standout, d=bold, u=underlined, k=blink.
581: .\" color is a pair of numbers separated by a period.
582: .\" The first number selects the foreground color and the second selects
583: .\" the background color of the text.
584: .\" A single number N is the same as N.0.
585: .It Fl e | -quit-at-eof
586: Causes
587: .Nm
588: to automatically exit the second time it reaches end-of-file.
589: By default, the only way to exit
590: .Nm
591: is via the "q" command.
592: .It Fl E | -QUIT-AT-EOF
593: Causes
594: .Nm
595: to automatically exit the first time it reaches end-of-file.
596: .It Fl f | -force
597: Forces non-regular files to be opened.
598: (A non-regular file is a directory or a device special file.)
599: Also suppresses the warning message when a binary file is opened.
600: By default,
601: .Nm
602: will refuse to open non-regular files.
603: .It Fl F | -quit-if-one-screen
604: Causes
605: .Nm
606: to automatically exit if the entire file can be displayed on the first screen.
607: .It Fl g | -hilite-search
608: Normally,
609: .Nm
610: will highlight ALL strings which match the last search command.
611: The -g option changes this behavior to highlight only the particular string
612: which was found by the last search command.
613: This can cause
614: .Nm
615: to run somewhat faster than the default.
616: .It Fl G | -HILITE-SEARCH
617: The -G option suppresses all highlighting of strings found by search commands.
618: .It Xo
619: .Fl h Ns Ar n |
620: .Fl -max-back-scroll Ns No = Ns Ar n
621: .Xc
622: Specifies a maximum number of lines to scroll backward.
623: If it is necessary to scroll backward more than n lines,
624: the screen is repainted in a forward direction instead.
625: (If the terminal does not have the ability to scroll backward, -h0 is implied.)
626: .It Fl i | -ignore-case
627: Causes searches to ignore case; that is,
628: uppercase and lowercase are considered identical.
629: This option is ignored if any uppercase letters appear in the search pattern;
630: in other words,
631: if a pattern contains uppercase letters, then that search does not ignore case.
632: .It Fl I | -IGNORE-CASE
633: Like -i, but searches ignore case even if the pattern contains uppercase
634: letters.
635: .It Xo
636: .Fl j Ns Ar n |
637: .Fl -jump-target Ns No = Ns Ar n
638: .Xc
639: Specifies a line on the screen where the "target" line is to be positioned.
640: A target line is the object of a text search,
641: tag search, jump to a line number,
642: jump to a file percentage, or jump to a marked position.
643: The screen line is specified by a number: the top line on the screen
644: is 1, the next is 2, and so on.
645: The number may be negative to specify a line relative to the bottom
646: of the screen: the bottom line on the screen is -1, the second
647: to the bottom is -2, and so on.
648: If the -j option is used, searches begin at the line immediately
649: after the target line.
650: For example, if "-j4" is used, the target line is the
651: fourth line on the screen, so searches begin at the fifth line on the screen.
652: .It Fl J | -status-column
653: Displays a status column at the left edge of the screen.
654: The status column shows the lines that matched the current search.
655: The status column is also used if the -w or -W option is in effect.
656: .It Xo
657: .Fl k Ns Ar filename |
658: .Fl -lesskey-file Ns No = Ns Ar filename
659: .Xc
660: Causes
661: .Nm
662: to open and interpret the named file as a
663: .Xr lesskey 1
664: file.
665: Multiple -k options may be specified.
666: If the
667: .Ev LESSKEY
668: or
669: .Ev LESSKEY_SYSTEM
670: environment variable is set, or if a lesskey file is found in a standard place
671: (see
672: .Sx KEY BINDINGS ) ,
673: it is also used as a lesskey file.
674: .It Fl L | -no-lessopen
675: Ignore the
676: .Ev LESSOPEN
677: environment variable (see the
678: .Sx INPUT PREPROCESSOR
679: section below).
680: This option can be set from within
681: .Nm less ,
682: but it will apply only to files opened subsequently, not to the
683: file which is currently open.
684: When invoked as
685: .Nm more ,
686: the
687: .Ev LESSOPEN
688: environment variable is ignored by default.
689: .It Fl m | -long-prompt
690: Causes
691: .Nm
692: to prompt verbosely (like more), with the percent into the file.
693: By default,
694: .Nm
695: prompts with a colon.
696: .It Fl M | -LONG-PROMPT
697: Causes
698: .Nm
699: to prompt even more verbosely than
700: .Nm more .
701: .It Fl n | -line-numbers
702: Suppresses line numbers.
703: The default (to use line numbers) may cause
704: .Nm
705: to run more slowly in some cases, especially with a very large input file.
706: Suppressing line numbers with the -n option will avoid this problem.
707: Using line numbers means: the line number will be displayed in the verbose
708: prompt and in the = command, and the v command will pass the current line
709: number to the editor (see also the discussion of LESSEDIT in
710: .Sx PROMPTS
711: below).
712: .It Fl N | -LINE-NUMBERS
713: Causes a line number to be displayed at the beginning of each line in the
714: display.
715: .It Xo
716: .Fl o Ns Ar filename |
717: .Fl -log-file Ns No = Ns Ar filename
718: .Xc
719: Causes
720: .Nm
721: to copy its input to the named file as it is being viewed.
722: This applies only when the input file is a pipe, not an ordinary file.
723: If the file already exists,
724: .Nm
725: will ask for confirmation before overwriting it.
726: .It Xo
727: .Fl O Ns Ar filename |
728: .Fl -LOG-FILE Ns No = Ns Ar filename
729: .Xc
730: The -O option is like -o, but it will overwrite an existing
731: file without asking for confirmation.
732: .Pp
733: If no log file has been specified,
734: the -o and -O options can be used from within
735: .Nm
736: to specify a log file.
737: Without a file name, they will simply report the name of the log file.
738: The "s" command is equivalent to specifying -o from within
739: .Nm less .
740: .It Xo
741: .Fl p Ns Ar pattern |
742: .Fl -pattern Ns No = Ns Ar pattern
743: .Xc
744: The -p option on the command line is equivalent to specifying +/pattern;
745: that is, it tells
746: .Nm
747: to start at the first occurrence of pattern in the file.
748: .It Xo
749: .Fl P Ns Ar prompt |
750: .Fl -prompt Ns No = Ns Ar prompt
751: .Xc
752: Provides a way to tailor the three prompt styles to your own preference.
753: This option would normally be put in the
754: .Ev LESS
755: environment variable, rather than being typed in with each
756: .Nm
757: command.
758: Such an option must either be the last option in the
759: .Ev LESS
760: variable, or be terminated by a dollar sign.
761: -Ps followed by a string changes the default (short) prompt to that string.
762: -Pm changes the medium (-m) prompt.
763: -PM changes the long (-M) prompt.
764: -Ph changes the prompt for the help screen.
765: -P= changes the message printed by the = command.
766: -Pw changes the message printed while waiting for data (in the F command).
767: All prompt strings consist of a sequence of letters and special escape
768: sequences.
769: See the section on
770: .Sx PROMPTS
771: for more details.
772: .It Fl q | -quiet | -silent
773: Causes moderately "quiet" operation:
774: the terminal bell is not rung if an attempt is made to scroll past the end
775: of the file or before the beginning of the file.
776: If the terminal has a "visual bell", it is used instead.
777: The bell will be rung on certain other errors,
778: such as typing an invalid character.
779: The default is to ring the terminal bell in all such cases.
780: .It Fl Q | -QUIET | -SILENT
781: Causes totally "quiet" operation: the terminal bell is never rung.
782: .It Fl r | -raw-control-chars
783: Causes "raw" control characters to be displayed.
784: The default is to display control characters using the caret notation;
785: for example, a control-A (octal 001) is displayed as "^A".
786: Warning: when the -r option is used,
787: .Nm
788: cannot keep track of the actual appearance of the screen
789: (since this depends on how the screen responds to
790: each type of control character).
791: Thus, various display problems may result,
792: such as long lines being split in the wrong place.
793: .It Fl R | -RAW-CONTROL-CHARS
794: Like -r, but tries to keep track of the screen appearance where possible.
795: This works only if the input consists of normal text and possibly some
796: ANSI "color" escape sequences, which are sequences of the form:
797: .Pp
798: ESC [ ... m
799: .Pp
800: where the "..." is zero or more characters other than "m".
801: For the purpose of keeping track of screen appearance,
802: all control characters and all ANSI color escape sequences are
803: assumed to not move the cursor.
804: You can make
805: .Nm
806: think that characters other than "m" can end ANSI color escape sequences
807: by setting the environment variable
808: .Ev LESSANSIENDCHARS
809: to the list of characters which can end a color escape sequence.
810: .It Fl s | -squeeze-blank-lines
811: Causes consecutive blank lines to be squeezed into a single blank line.
812: This is useful when viewing
813: .Xr nroff 1
814: output.
815: .It Fl S | -chop-long-lines
816: Causes lines longer than the screen width to be chopped rather than folded.
817: That is, the portion of a long line that does not fit in
818: the screen width is not shown.
819: The default is to fold long lines; that is, display the remainder
820: on the next line.
821: .It Xo
822: .Fl t Ns Ar tag |
823: .Fl -tag Ns No = Ns Ar tag
824: .Xc
825: The -t option, followed immediately by a TAG,
826: will edit the file containing that tag.
827: For this to work, tag information must be available;
828: for example, there may be a file in the current directory called "tags",
829: which was previously built by
830: .Xr ctags 1
831: or an equivalent command.
832: If the environment variable
833: .Ev LESSGLOBALTAGS
834: is set, it is taken to be the name of a command compatible with
835: .Xr global ,
836: and that command is executed to find the tag.
837: (See http://www.gnu.org/software/global/global.html).
838: The -t option may also be specified from within
839: .Nm
840: (using the \- command) as a way of examining a new file.
841: The command ":t" is equivalent to specifying -t from within
842: .Nm less .
843: .It Xo
844: .Fl T Ns Ar tagsfile |
845: .Fl -tag-file Ns No = Ns Ar tagsfile
846: .Xc
847: Specifies a tags file to be used instead of "tags".
848: .It Fl u | -underline-special
849: Causes backspaces and carriage returns to be treated as printable characters;
850: that is, they are sent to the terminal when they appear in the input.
851: .It Fl U | -UNDERLINE-SPECIAL
852: Causes backspaces, tabs and carriage returns to be
853: treated as control characters;
854: that is, they are handled as specified by the -r option.
855: .Pp
856: By default, if neither -u nor -U is given, backspaces which appear adjacent
857: to an underscore character are treated specially:
858: the underlined text is displayed
859: using the terminal's hardware underlining capability.
860: Also, backspaces which appear between two identical characters
861: are treated specially:
862: the overstruck text is printed
863: using the terminal's hardware boldface capability.
864: Other backspaces are deleted, along with the preceding character.
865: Carriage returns immediately followed by a newline are deleted.
866: Other carriage returns are handled as specified by the -r option.
867: Text which is overstruck or underlined can be searched for
868: if neither -u nor -U is in effect.
869: .It Fl V | -version
870: Displays the version number of
871: .Nm less .
872: .It Fl w | -hilite-unread
873: Temporarily highlights the first "new" line after a forward movement
874: of a full page.
875: The first "new" line is the line immediately following the line previously
876: at the bottom of the screen.
877: Also highlights the target line after a g or p command.
878: The highlight is removed at the next command which causes movement.
879: The entire line is highlighted, unless the -J option is in effect,
880: in which case only the status column is highlighted.
881: .It Fl W | -HILITE-UNREAD
882: Like -w, but temporarily highlights the first new line after any
883: forward movement command larger than one line.
884: .It Xo
885: .Fl x Ns Ar n,... |
886: .Fl -tabs Ns No = Ns Ar n,...
887: .Xc
888: Sets tab stops.
889: If only one n is specified, tab stops are set at multiples of n.
890: If multiple values separated by commas are specified, tab stops are set at
891: those positions, and then continue with the same spacing as the last two.
892: For example, -x9,17 will set tabs at positions 9, 17, 25, 33, etc.
893: The default for n is 8.
894: .It Fl X | -no-init
895: Disables sending the termcap initialization and deinitialization strings
896: to the terminal.
897: This is sometimes desirable if the deinitialization string does
898: something unnecessary, like clearing the screen.
899: .It Fl -no-keypad
900: Disables sending the keypad initialization and deinitialization strings
901: to the terminal.
902: This is sometimes useful if the keypad strings make the numeric
903: keypad behave in an undesirable manner.
904: .It Xo
905: .Fl y Ns Ar n |
906: .Fl -max-forw-scroll Ns No = Ns Ar n
907: .Xc
908: Specifies a maximum number of lines to scroll forward.
909: If it is necessary to scroll forward more than n lines,
910: the screen is repainted instead.
911: The -c or -C option may be used to repaint from the top of
912: the screen if desired.
913: By default, any forward movement causes scrolling.
914: .It Xo
915: .Fl Oo Cm z Oc Ns Ar n |
916: .Fl -window Ns No = Ns Ar n
917: .Xc
918: Changes the default scrolling window size to n lines.
919: The default is one screenful.
920: The z and w commands can also be used to change the window size.
921: The "z" may be omitted for compatibility with
922: .Nm more .
923: If the number
924: .Ar n
925: is negative, it indicates
926: .Ar n
927: lines less than the current screen size.
928: For example, if the screen is 24 lines, -z-4 sets the
929: scrolling window to 20 lines.
930: If the screen is resized to 40 lines,
931: the scrolling window automatically changes to 36 lines.
932: .It Xo
933: .Ar -cc |
934: .Fl -quotes Ns No = Ns Ar cc
935: .Xc
936: Changes the filename quoting character.
937: This may be necessary if you are trying to name a file
938: which contains both spaces and quote characters.
939: Followed by a single character, this changes the quote character to that
940: character.
941: Filenames containing a space should then be surrounded by that character
942: rather than by double quotes.
943: Followed by two characters, changes the open quote to the first character,
944: and the close quote to the second character.
945: Filenames containing a space should then be preceded by the open quote
946: character and followed by the close quote character.
947: Note that even after the quote characters are changed, this option
948: remains -" (a dash followed by a double quote).
949: .It Fl ~ | -tilde
950: Normally lines after end of file are displayed as a single tilde (~).
951: This option causes lines after end of file to be displayed as blank lines.
952: .It Fl # | -shift
953: Specifies the default number of positions to scroll horizontally
954: in the RIGHTARROW and LEFTARROW commands.
955: If the number specified is zero, it sets the default number of
956: positions to one half of the screen width.
957: .It Fl -
958: A command line argument of "--" marks the end of option arguments.
959: Any arguments following this are interpreted as filenames.
960: This can be useful when viewing a file whose name begins with a "-" or "+".
961: .It Cm +
962: If a command line option begins with +,
963: the remainder of that option is taken to be an initial command to
964: .Nm less .
965: For example, +G tells
966: .Nm
967: to start at the end of the file rather than the beginning,
968: and +/xyz tells it to start at the first occurrence of "xyz" in the file.
969: As a special case, +<number> acts like +<number>g;
970: that is, it starts the display at the specified line number
971: (however, see the caveat under the "g" command above).
972: If the option starts with ++, the initial command applies to
973: every file being viewed, not just the first one.
974: The + command described previously
975: may also be used to set (or change) an initial command for every file.
976: .El
977: .Sh LINE EDITING
978: When entering command line at the bottom of the screen
979: (for example, a filename for the :e command,
980: or the pattern for a search command),
981: certain keys can be used to manipulate the command line.
982: Most commands have an alternate form in [ brackets ] which can be used if
983: a key does not exist on a particular keyboard.
984: .\" (The bracketed forms do not work in the MS-DOS version.)
985: Any of these special keys may be entered literally by preceding
986: it with the "literal" character, either ^V or ^A.
987: A backslash itself may also be entered literally by entering two backslashes.
988: .Pp
989: .Bl -tag -width Ds
990: .It LEFTARROW [ ESC-h ]
991: Move the cursor one space to the left.
992: .It RIGHTARROW [ ESC-l ]
993: Move the cursor one space to the right.
994: .It ^LEFTARROW [ ESC-b or ESC-LEFTARROW ]
995: (That is, CONTROL and LEFTARROW simultaneously.)
996: Move the cursor one word to the left.
997: .It ^RIGHTARROW [ ESC-w or ESC-RIGHTARROW ]
998: (That is, CONTROL and RIGHTARROW simultaneously.)
999: Move the cursor one word to the right.
1000: .It HOME [ ESC-0 ]
1001: Move the cursor to the beginning of the line.
1002: .It END [ ESC-$ ]
1003: Move the cursor to the end of the line.
1004: .It BACKSPACE
1005: Delete the character to the left of the cursor,
1006: or cancel the command if the command line is empty.
1007: .It DELETE or [ ESC-x ]
1008: Delete the character under the cursor.
1009: .It ^BACKSPACE [ ESC-BACKSPACE ]
1010: (That is, CONTROL and BACKSPACE simultaneously.)
1011: Delete the word to the left of the cursor.
1012: .It ^DELETE [ ESC-X or ESC-DELETE ]
1013: (That is, CONTROL and DELETE simultaneously.)
1014: Delete the word under the cursor.
1015: .It UPARROW [ ESC-k ]
1016: Retrieve the previous command line.
1017: .It DOWNARROW [ ESC-j ]
1018: Retrieve the next command line.
1019: .It TAB
1020: Complete the partial filename to the left of the cursor.
1021: If it matches more than one filename, the first match
1022: is entered into the command line.
1023: Repeated TABs will cycle through the other matching filenames.
1024: If the completed filename is a directory, a "/" is appended to the filename.
1025: .\" (On MS-DOS systems, a "\e" is appended.)
1026: The environment variable
1027: .Ev LESSSEPARATOR
1028: can be used to specify a different character to append to a directory name.
1029: .It BACKTAB [ ESC-TAB ]
1030: Like TAB, but cycles in the reverse direction through the matching filenames.
1031: .It ^L
1032: Complete the partial filename to the left of the cursor.
1033: If it matches more than one filename, all matches are entered into
1034: the command line (if they fit).
1035: .\" .It ^U (Unix and OS/2) or ESC (MS-DOS)
1036: .It ^U
1037: Delete the entire command line,
1038: or cancel the command if the command line is empty.
1039: If you have changed your line-kill character to something
1040: other than ^U, that character is used instead of ^U.
1041: .El
1042: .Sh KEY BINDINGS
1043: You may define your own
1044: .Nm
1045: commands by using the program
1046: .Xr lesskey 1
1047: to create a lesskey file.
1048: This file specifies a set of command keys and an action
1049: associated with each key.
1050: You may also use lesskey
1051: to change the line-editing keys (see
1052: .Sx LINE EDITING ) ,
1053: and to set environment variables.
1054: If the environment variable
1055: .Ev LESSKEY
1056: is set,
1057: .Nm
1058: uses that as the name of the lesskey file.
1059: Otherwise,
1060: .Nm
1061: looks for a lesskey file called "$HOME/.less".
1062: .\" On MS-DOS and Windows systems,
1063: .\" .I less
1064: .\" looks for a lesskey file called "$HOME/_less", and if it is not found there,
1065: .\" then looks for a lesskey file called "_less" in any directory specified
1066: .\" in the PATH environment variable.
1067: .\" On OS/2 systems,
1068: .\" .I less
1069: .\" looks for a lesskey file called "$HOME/less.ini", and if it is not found,
1070: .\" then looks for a lesskey file called "less.ini" in any directory specified
1071: .\" in the INIT environment variable, and if it not found there,
1072: .\" then looks for a lesskey file called "less.ini" in any directory specified
1073: .\" in the PATH environment variable.
1074: See the
1075: .Xr lesskey 1
1076: manual page for more details.
1077: .Pp
1078: A system-wide lesskey file may also be set up to provide key bindings.
1079: If a key is defined in both a local lesskey file and in the
1080: system-wide file, key bindings in the local file take precedence over
1081: those in the system-wide file.
1082: If the environment variable
1083: .Ev LESSKEY_SYSTEM
1084: is set,
1085: .Nm
1086: uses that as the name of the system-wide lesskey file.
1087: Otherwise,
1088: .Nm
1089: looks in a standard place for the system-wide lesskey file:
1090: On
1091: .Ox ,
1092: the system-wide lesskey file is
1093: .Pa /etc/sysless .
1094: .\" On Unix systems, the system-wide lesskey file is /usr/local/etc/sysless.
1095: .\" (However, if
1096: .\" .Nm less
1097: .\" was built with a different sysconf directory than /usr/local/etc,
1098: .\" that directory is where the sysless file is found.)
1099: .\" On MS-DOS and Windows systems, the system-wide lesskey file is c:\e_sysless.
1100: .\" On OS/2 systems, the system-wide lesskey file is c:\esysless.ini.
1101: .Sh INPUT PREPROCESSOR
1102: You may define an "input preprocessor" for
1103: .Nm less .
1104: Before
1105: .Nm less
1106: opens a file, it first gives your input preprocessor a chance to modify the
1107: way the contents of the file are displayed.
1108: An input preprocessor is simply an executable program (or shell script),
1109: which writes the contents of the file to a different file,
1110: called the replacement file.
1111: The contents of the replacement file are then displayed
1112: in place of the contents of the original file.
1113: However, it will appear to the user as if the original file is opened;
1114: that is,
1115: .Nm less
1116: will display the original filename as the name of the current file.
1117: .Pp
1118: An input preprocessor receives one command line argument, the original filename,
1119: as entered by the user.
1120: It should create the replacement file, and when finished
1121: print the name of the replacement file to its standard output.
1122: If the input preprocessor does not output a replacement filename,
1123: .Nm
1124: uses the original file, as normal.
1125: The input preprocessor is not called when viewing standard input.
1126: To set up an input preprocessor, set the
1127: .Ev LESSOPEN
1128: environment variable to a command line which will invoke your
1129: input preprocessor.
1130: This command line should include one occurrence of the string "%s",
1131: which will be replaced by the filename
1132: when the input preprocessor command is invoked.
1133: .Pp
1134: When
1135: .Nm
1136: closes a file opened in such a way, it will call another program,
1137: called the input postprocessor,
1138: which may perform any desired clean-up action (such as deleting the
1139: replacement file created by
1140: .Ev LESSOPEN ) .
1141: This program receives two command line arguments, the original filename
1142: as entered by the user, and the name of the replacement file.
1143: To set up an input postprocessor, set the
1144: .Ev LESSCLOSE
1145: environment variable to a command line which will invoke your
1146: input postprocessor.
1147: It may include two occurrences of the string "%s";
1148: the first is replaced with the original name of the file and the second
1149: with the name of the replacement file, which was output by
1150: .Ev LESSOPEN .
1151: .Pp
1152: For example, these two scripts will allow you
1153: to keep files in compressed format, but still let
1154: .Nm
1155: view them directly:
1156: .Pp
1157: lessopen.sh:
1158: .Bd -literal -offset indent
1159: #! /bin/sh
1160: case "$1" in
1161: *.Z) uncompress -c $1 >/tmp/less.$$ 2>/dev/null
1162: if [ -s /tmp/less.$$ ]; then
1163: echo /tmp/less.$$
1164: else
1165: rm -f /tmp/less.$$
1166: fi
1167: ;;
1168: esac
1169: .Ed
1170: .Pp
1171: lessclose.sh:
1172: .Bd -literal -offset indent
1173: #! /bin/sh
1174: rm $2
1175: .Ed
1176: .Pp
1177: To use these scripts, put them both where they can be executed and
1178: set LESSOPEN="lessopen.sh\ %s", and LESSCLOSE="lessclose.sh\ %s\ %s".
1179: More complex LESSOPEN and LESSCLOSE scripts may be written
1180: to accept other types of compressed files, and so on.
1181: .Pp
1182: It is also possible to set up an input preprocessor to
1183: pipe the file data directly to
1184: .Nm less ,
1185: rather than putting the data into a replacement file.
1186: This avoids the need to decompress the entire file before starting to view it.
1187: An input preprocessor that works this way is called an input pipe.
1188: An input pipe, instead of writing the name of a replacement file on
1189: its standard output,
1190: writes the entire contents of the replacement file on its standard output.
1191: If the input pipe does not write any characters on its standard output,
1192: then there is no replacement file and
1193: .Nm
1194: uses the original file, as normal.
1195: To use an input pipe, make the first character in the
1196: .Ev LESSOPEN
1197: environment variable a vertical bar (|) to signify that the
1198: input preprocessor is an input pipe.
1199: .Pp
1200: For example, this script will work like the previous example scripts:
1201: .Pp
1202: lesspipe.sh:
1203: .Bd -literal -offset indent
1204: #! /bin/sh
1205: case "$1" in
1206: *.Z) uncompress -c $1 2>/dev/null
1207: ;;
1208: esac
1209: .Ed
1210: .Pp
1211: To use this script, put it where it can be executed and set
1212: LESSOPEN="|lesspipe.sh %s".
1213: When an input pipe is used, a LESSCLOSE postprocessor can be used,
1214: but it is usually not necessary since there is no replacement file to clean up.
1215: In this case, the replacement file name passed to the LESSCLOSE
1216: postprocessor is "-".
1217: .Sh NATIONAL CHARACTER SETS
1218: There are three types of characters in the input file:
1219: .Bl -tag -width "control characters"
1220: .It normal characters
1221: Can be displayed directly to the screen.
1222: .It control characters
1223: Should not be displayed directly, but are expected to be found
1224: in ordinary text files (such as backspace and tab).
1225: .It binary characters
1226: Should not be displayed directly and are not expected to be found
1227: in text files.
1228: .El
1229: .Pp
1230: A "character set" is simply a description of which characters are to
1231: be considered normal, control, and binary.
1232: The
1233: .Ev LESSCHARSET
1234: environment variable may be used to select a character set.
1235: Possible values for
1236: .Ev LESSCHARSET
1237: are:
1238: .Bl -tag -width "IBM-1047"
1239: .It ascii
1240: BS, TAB, NL, CR, and formfeed are control characters,
1241: all chars with values between 32 and 126 are normal,
1242: and all others are binary.
1243: .It iso8859
1244: Selects an ISO 8859 character set.
1245: This is the same as ASCII, except characters between 160 and 255 are
1246: treated as normal characters.
1247: .It latin1
1248: Same as iso8859.
1249: .It latin9
1250: Same as iso8859.
1251: .It dos
1252: Selects a character set appropriate for MS-DOS.
1253: .It ebcdic
1254: Selects an EBCDIC character set.
1255: .It IBM-1047
1256: Selects an EBCDIC character set used by OS/390 Unix Services.
1257: This is the EBCDIC analogue of latin1.
1258: You get similar results by setting either LESSCHARSET=IBM-1047 or
1259: LC_CTYPE=en_US in your environment.
1260: .It koi8-r
1261: Selects a Russian character set.
1262: .It next
1263: Selects a character set appropriate for NeXT computers.
1264: .It utf-8
1265: Selects the UTF-8 encoding of the ISO 10646 character set.
1266: .El
1267: .Pp
1268: In special cases, it may be desired to tailor
1269: .Nm
1270: to use a character set other than the ones definable by LESSCHARSET.
1271: In this case, the environment variable
1272: .Ev LESSCHARDEF
1273: can be used to define a character set.
1274: It should be set to a string where each character in the string represents
1275: one character in the character set.
1276: The character "." is used for a normal character, "c" for control,
1277: and "b" for binary.
1278: A decimal number may be used for repetition.
1279: For example, "bccc4b." would mean character 0 is binary,
1280: 1, 2 and 3 are control, 4, 5, 6 and 7 are binary, and 8 is normal.
1281: All characters after the last are taken to be the same as the last,
1282: so characters 9 through 255 would be normal.
1283: (This is an example, and does not necessarily
1284: represent any real character set.)
1285: .Pp
1286: This table shows the value of LESSCHARDEF which is equivalent
1287: to each of the possible values for LESSCHARSET:
1288: .Pp
1289: .Bd -literal -offset indent
1290: ascii 8bcccbcc18b95.b
1291: dos 8bcccbcc12bc5b95.b.
1292: ebcdic 5bc6bcc7bcc41b.9b7.9b5.b..8b6.10b6.b9.7b
1293: 9.8b8.17b3.3b9.7b9.8b8.6b10.b.b.b.
1294: IBM-1047 4cbcbc3b9cbccbccbb4c6bcc5b3cbbc4bc4bccbc
1295: 191.b
1296: iso8859 8bcccbcc18b95.33b.
1297: koi8-r 8bcccbcc18b95.b128.
1298: latin1 8bcccbcc18b95.33b.
1299: next 8bcccbcc18b95.bb125.bb
1300: .Ed
1301: .Pp
1302: If neither LESSCHARSET nor LESSCHARDEF is set,
1303: but the string "UTF-8" is found in the
1304: .Ev LC_ALL , LC_TYPE
1305: or
1306: .Ev LANG
1307: environment variables, then the default character set is utf-8.
1308: .Pp
1309: If that string is not found, but your system supports the
1310: setlocale interface,
1311: .Nm
1312: will use setlocale to determine the character set.
1313: setlocale is controlled by setting the
1314: .Ev LANG
1315: or
1316: .Ev LC_CTYPE
1317: environment variables.
1318: .Pp
1319: Finally, if the
1320: setlocale interface is also not available, the default character set is latin1.
1321: .Pp
1322: Control and binary characters are displayed in standout (reverse video).
1323: Each such character is displayed in caret notation if possible
1324: (e.g. ^A for control-A).
1325: Caret notation is used only if inverting the 0100 bit results in a
1326: normal printable character.
1327: Otherwise, the character is displayed as a hex number in angle brackets.
1328: This format can be changed by setting the
1329: .Ev LESSBINFMT
1330: environment variable.
1331: LESSBINFMT may begin with a "*" and one character to select
1332: the display attribute:
1333: "*k" is blinking, "*d" is bold, "*u" is underlined, "*s" is standout,
1334: and "*n" is normal.
1335: If LESSBINFMT does not begin with a "*", normal attribute is assumed.
1336: The remainder of LESSBINFMT is a string which may include one
1337: printf-style escape sequence (a % followed by x, X, o, d, etc.).
1338: For example, if LESSBINFMT is "*u[%x]", binary characters
1339: are displayed in underlined hexadecimal surrounded by brackets.
1340: The default if no LESSBINFMT is specified is "*s<%X>".
1341: .Sh PROMPTS
1342: The -P option allows you to tailor the prompt to your preference.
1343: The string given to the -P option replaces the specified prompt string.
1344: Certain characters in the string are interpreted specially.
1345: The prompt mechanism is rather complicated to provide flexibility,
1346: but the ordinary user need not understand the details of constructing
1347: personalized prompt strings.
1348: .Pp
1349: A percent sign followed by a single character is expanded
1350: according to what the following character is:
1351: .Bl -tag -width Ds
1352: .It %b Ns Ar X
1353: Replaced by the byte offset into the current input file.
1354: The b is followed by a single character (shown as
1355: .Ar X
1356: above) which specifies the line whose byte offset is to be used.
1357: If the character is a "t", the byte offset of the top line in the
1358: display is used,
1359: an "m" means use the middle line,
1360: a "b" means use the bottom line,
1361: a "B" means use the line just after the bottom line,
1362: and a "j" means use the "target" line, as specified by the -j option.
1363: .It %B
1364: Replaced by the size of the current input file.
1365: .It %c
1366: Replaced by the column number of the text appearing in the first
1367: column of the screen.
1368: .It %d Ns Ar X
1369: Replaced by the page number of a line in the input file.
1370: The line to be used is determined by the
1371: .Ar X ,
1372: as with the %b option.
1373: .It %D
1374: Replaced by the number of pages in the input file,
1375: or equivalently, the page number of the last line in the input file.
1376: .It %E
1377: Replaced by the name of the editor (from the
1378: .Ev VISUAL
1379: environment variable, or the
1380: .Ev EDITOR
1381: environment variable if
1382: .Ev VISUAL
1383: is not defined).
1384: See the discussion of the LESSEDIT feature below.
1385: .It %f
1386: Replaced by the name of the current input file.
1387: .It %i
1388: Replaced by the index of the current file in the list of
1389: input files.
1390: .It %l Ns Ar X
1391: Replaced by the line number of a line in the input file.
1392: The line to be used is determined by the
1393: .Ar X ,
1394: as with the %b option.
1395: .It %L
1396: Replaced by the line number of the last line in the input file.
1397: .It %m
1398: Replaced by the total number of input files.
1399: .It %p Ns Ar X
1400: Replaced by the percent into the current input file, based on byte offsets.
1401: The line used is determined by the
1402: .Ar X ,
1403: as with the %b option.
1404: .It %P Ns Ar X
1405: Replaced by the percent into the current input file, based on line numbers.
1406: The line used is determined by the
1407: .Ar X ,
1408: as with the %b option.
1409: .It %s
1410: Same as %B.
1411: .It %t
1412: Causes any trailing spaces to be removed.
1413: Usually used at the end of the string, but may appear anywhere.
1414: .It %x
1415: Replaced by the name of the next input file in the list.
1416: .El
1417: .Pp
1418: If any item is unknown (for example, the file size if input is a pipe),
1419: a question mark is printed instead.
1420: .Pp
1421: The format of the prompt string can be changed depending on certain conditions.
1422: A question mark followed by a single character acts like an "IF":
1423: depending on the following character, a condition is evaluated.
1424: If the condition is true, any characters following the question mark
1425: and condition character, up to a period, are included in the prompt.
1426: If the condition is false, such characters are not included.
1427: A colon appearing between the question mark and the
1428: period can be used to establish an "ELSE": any characters between
1429: the colon and the period are included in the string, if and only if
1430: the IF condition is false.
1431: Condition characters (which follow a question mark) may be:
1432: .Bl -tag -width Ds
1433: .It ?a
1434: True if any characters have been included in the prompt so far.
1435: .It ?b Ns Ar X
1436: True if the byte offset of the specified line is known.
1437: .It ?B
1438: True if the size of the current input file is known.
1439: .It ?c
1440: True if the text is horizontally shifted (%c is not zero).
1441: .It ?d Ns Ar X
1442: True if the page number of the specified line is known.
1443: .It ?e
1444: True if at end-of-file.
1445: .It ?f
1446: True if there is an input filename
1447: (that is, if input is not a pipe).
1448: .It ?l Ns Ar X
1449: True if the line number of the specified line is known.
1450: .It ?L
1451: True if the line number of the last line in the file is known.
1452: .It ?m
1453: True if there is more than one input file.
1454: .It ?n
1455: True if this is the first prompt in a new input file.
1456: .It ?p Ns Ar X
1457: True if the percent into the current input file, based on byte offsets,
1458: of the specified line is known.
1459: .It ?P Ns Ar X
1460: True if the percent into the current input file, based on line numbers,
1461: of the specified line is known.
1462: .It ?s
1463: Same as "?B".
1464: .It ?x
1465: True if there is a next input file
1466: (that is, if the current input file is not the last one).
1467: .El
1468: .Pp
1469: Any characters other than the special ones
1470: (question mark, colon, period, percent, and backslash)
1471: become literally part of the prompt.
1472: Any of the special characters may be included in the prompt literally
1473: by preceding it with a backslash.
1474: .Pp
1475: Some examples:
1476: .Pp
1477: .Dl ?f%f:Standard input.
1478: .Pp
1479: This prompt prints the filename, if known;
1480: otherwise the string "Standard input".
1481: .Pp
1482: .Dl ?f%f .?ltLine %lt:?pt%pt\e%:?btByte %bt:-...
1483: .Pp
1484: This prompt would print the filename, if known.
1485: The filename is followed by the line number, if known,
1486: otherwise the percent if known, otherwise the byte offset if known.
1487: Otherwise, a dash is printed.
1488: Notice how each question mark has a matching period,
1489: and how the % after the %pt
1490: is included literally by escaping it with a backslash.
1491: .Pp
1492: .Dl ?n?f%f\ .?m(file\ %i\ of\ %m)\ ..?e(END)\ ?x-\ Next\e:\ %x..%t
1493: .Pp
1494: This prints the filename if this is the first prompt in a file,
1495: followed by the "file N of N" message if there is more
1496: than one input file.
1497: Then, if we are at end-of-file, the string "(END)" is printed
1498: followed by the name of the next file, if there is one.
1499: Finally, any trailing spaces are truncated.
1500: This is the default prompt.
1501: For reference, here are the defaults for
1502: the other two prompts (-m and -M respectively).
1503: Each is broken into two lines here for readability only.
1504: .Pp
1505: .Bd -literal -offset indent
1506: ?n?f%f\ .?m(file\ %i\ of\ %m)\ ..?e(END)\ ?x-\ Next\e:\ %x.:
1507: ?pB%pB\e%:byte\ %bB?s/%s...%t
1508:
1509: ?f%f\ .?n?m(file\ %i\ of\ %m)\ ..?ltlines\ %lt-%lb?L/%L.\ :
1510: byte\ %bB?s/%s.\ .?e(END)\ ?x-\ Next\e:\ %x.:?pB%pB\e%..%t
1511: .Ed
1512: .Pp
1513: And here is the default message produced by the = command:
1514: .Pp
1515: .Bd -literal -offset indent
1516: ?f%f\ .?m(file\ %i\ of\ %m)\ .?ltlines\ %lt-%lb?L/%L.\ .
1517: byte\ %bB?s/%s.\ ?e(END)\ :?pB%pB\e%..%t
1518: .Ed
1519: .Pp
1520: The prompt expansion features are also used for another purpose:
1521: if an environment variable
1522: .Ev LESSEDIT
1523: is defined, it is used as the command to be executed when the v command
1524: is invoked.
1525: The LESSEDIT string is expanded in the same way as the prompt strings.
1526: The default value for LESSEDIT is:
1527: .Pp
1528: .Dl %E\ ?lm+%lm.\ %f
1529: .Pp
1530: Note that this expands to the editor name, followed by a + and the
1531: line number, followed by the file name.
1532: If your editor does not accept the "+linenumber" syntax, or has other
1533: differences in invocation syntax, the
1534: .Ev LESSEDIT
1535: variable can be changed to modify this default.
1536: .Sh SECURITY
1537: When the environment variable
1538: .Ev LESSSECURE
1539: is set to 1,
1540: .Nm
1541: runs in a "secure" mode.
1542: This means these features are disabled:
1543: .Bl -tag -width Ds
1544: .It !
1545: The shell command.
1546: .It |
1547: The pipe command.
1548: .It :e
1549: The examine command.
1550: .It v
1551: The editing command.
1552: .It s -o
1553: Log files.
1554: .It -k
1555: Use of lesskey files.
1556: .It -t
1557: Use of tags files.
1558: .It " "
1559: Metacharacters in filenames, such as "*".
1560: .It " "
1561: Filename completion (TAB, ^L).
1562: .El
1563: .Pp
1564: Less can also be compiled to be permanently in "secure" mode.
1565: .Sh ENVIRONMENT VARIABLES
1566: Environment variables may be specified either in the system environment
1567: as usual, or in a
1568: .Xr lesskey 1
1569: file.
1570: If environment variables are defined in more than one place,
1571: variables defined in a local lesskey file take precedence over
1572: variables defined in the system environment, which take precedence
1573: over variables defined in the system-wide lesskey file.
1574: .Bl -tag -width Ds
1575: .It Ev COLUMNS
1576: Sets the number of columns on the screen.
1577: Takes precedence over the number of columns specified by the TERM variable.
1578: (But if you have a windowing system which supports TIOCGWINSZ or WIOCGETD,
1579: the window system's idea of the screen size takes precedence over the
1580: LINES and COLUMNS environment variables.)
1581: .It Ev EDITOR
1582: The name of the editor (used for the v command).
1583: .It Ev HOME
1584: Name of the user's home directory
1585: (used to find a lesskey file).
1586: .\" .It Ev "HOMEDRIVE, HOMEPATH"
1587: .\" Concatenation of the HOMEDRIVE and HOMEPATH environment variables is
1588: .\" the name of the user's home directory if the HOME variable is not set
1589: .\" (only in the Windows version).
1590: .\" .It Ev INIT
1591: .\" Name of the user's init directory
1592: .\" (used to find a lesskey file on OS/2 systems).
1593: .It Ev LANG
1594: Language for determining the character set.
1595: .It Ev LC_CTYPE
1596: Language for determining the character set.
1597: .It Ev LESS
1598: Options which are passed to
1599: .Nm
1600: automatically.
1601: .It Ev LESSANSIENDCHARS
1602: Characters which are assumed to end an ANSI color escape sequence
1603: (default "m").
1604: .It Ev LESSBINFMT
1605: Format for displaying non-printable, non-control characters.
1606: .It Ev LESSCHARDEF
1607: Defines a character set.
1608: .It Ev LESSCHARSET
1609: Selects a predefined character set.
1610: .It Ev LESSCLOSE
1611: Command line to invoke the (optional) input-postprocessor.
1612: .\" .It Ev LESSECHO
1613: .\" Name of the lessecho program (default "lessecho").
1614: .\" The lessecho program is needed to expand metacharacters, such as * and ?,
1615: .\" in filenames on Unix systems.
1616: .It Ev LESSEDIT
1617: Editor prototype string (used for the v command).
1618: See discussion under
1619: .Sx PROMPTS .
1620: .It Ev LESSGLOBALTAGS
1621: Name of the command used by the -t option to find global tags.
1622: Normally should be set to "global" if your system has the global command.
1623: If not set, global tags are not used.
1624: .It Ev LESSKEY
1625: Name of the default lesskey(1) file.
1626: .It Ev LESSKEY_SYSTEM
1627: Name of the default system-wide lesskey(1) file.
1628: .It Ev LESSMETACHARS
1629: List of characters which are considered "metacharacters" by the shell.
1630: .It Ev LESSMETAESCAPE
1631: Prefix which
1632: .Nm
1633: will add before each metacharacter in a command sent to the shell.
1634: If LESSMETAESCAPE is an empty string, commands containing
1635: metacharacters will not be passed to the shell.
1636: .It Ev LESSOPEN
1637: Command line to invoke the (optional) input-preprocessor.
1638: .It Ev LESSSECURE
1639: Runs less in "secure" mode.
1640: See discussion under
1641: .Sx SECURITY .
1642: .It Ev LESSSEPARATOR
1643: String to be appended to a directory name in filename completion.
1644: .It Ev LINES
1645: Sets the number of lines on the screen.
1646: Takes precedence over the number of lines specified by the TERM variable.
1647: (But if you have a windowing system which supports TIOCGWINSZ or WIOCGETD,
1648: the window system's idea of the screen size takes precedence over the
1649: LINES and COLUMNS environment variables.)
1650: .\" .It Ev PATH
1651: .\" User's search path (used to find a lesskey file
1652: .\" on MS-DOS and OS/2 systems).
1653: .It Ev SHELL
1654: The shell used to execute the ! command, as well as to expand filenames.
1655: .It Ev TERM
1656: The type of terminal on which
1657: .Nm
1658: is being run.
1659: .It Ev VISUAL
1660: The name of the editor (used for the v command).
1661: .El
1662: .Sh SEE ALSO
1663: .Xr lesskey 1
1664: .Sh WARNINGS
1665: The = command and prompts (unless changed by -P)
1666: report the line numbers of the lines at the top and bottom of the screen,
1667: but the byte and percent of the line after the one at the bottom of the screen.
1668: .Pp
1669: If the :e command is used to name more than one file,
1670: and one of the named files has been viewed previously,
1671: the new files may be entered into the list in an unexpected order.
1672: .Pp
1673: On certain older terminals (the so-called "magic cookie" terminals),
1674: search highlighting will cause an erroneous display.
1675: On such terminals, search highlighting is disabled by default
1676: to avoid possible problems.
1677: .Pp
1678: In certain cases, when search highlighting is enabled and
1679: a search pattern begins with a ^,
1680: more text than the matching string may be highlighted.
1681: (This problem does not occur when
1682: .Nm
1683: is compiled to use the POSIX regular expression package.)
1684: .Pp
1685: When viewing text containing ANSI color escape sequences using the -R option,
1686: searching will not find text containing an embedded escape sequence.
1687: Also, search highlighting may change the color of some of the text
1688: which follows the highlighted text.
1689: .Pp
1690: On some systems, setlocale claims that ASCII characters 0 through 31 are
1691: control characters rather than binary characters.
1692: This causes
1693: .Nm
1694: to treat some binary files as ordinary, non-binary files.
1695: To workaround this problem, set the environment variable
1696: .Ev LESSCHARSET
1697: to "ascii" (or whatever character set is appropriate).
1698: .Pp
1699: See
1700: .Pa http://www.greenwoodsoftware.com/less
1701: for the latest list of known bugs in this version of
1702: .Nm less .
1703: .Sh COPYRIGHT
1704: Copyright (C) 2002 Mark Nudelman
1705: .Pp
1706: less is part of the GNU project and is free software.
1707: You can redistribute it and/or modify it
1708: under the terms of either
1709: (1) the GNU General Public License as published by
1710: the Free Software Foundation; or (2) the Less License.
1711: See the file README in the less distribution for more details
1712: regarding redistribution.
1713: You should have received a copy of the GNU General Public License
1714: along with the source for less; see the file COPYING.
1715: If not, write to the Free Software Foundation, 59 Temple Place,
1716: Suite 330, Boston, MA 02111-1307, USA.
1717: You should also have received a copy of the Less License;
1718: see the file LICENSE.
1719: .Pp
1720: less is distributed in the hope that it will be useful, but
1721: WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
1722: or FITNESS FOR A PARTICULAR PURPOSE.
1723: See the GNU General Public License for more details.
1.2 ! jmc 1724: .Sh AUTHORS
1.1 millert 1725: .Pp
1726: Mark Nudelman <markn@greenwoodsoftware.com>
1727: .br
1728: Send bug reports or comments to the above address or to bug-less@gnu.org.
1729: .br
1730: For more information, see the less homepage at
1731: .Pa http://www.greenwoodsoftware.com/less .