Annotation of src/usr.bin/less/less.1, Revision 1.6
1.6 ! jmc 1: .\" $OpenBSD: less.1,v 1.5 2003/08/18 17:19:38 millert 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
11: .\" notice in the documentation and/or other materials provided with
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
16: .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17: .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
18: .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19: .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
20: .\" OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
21: .\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22: .\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
23: .\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
24: .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1.1 millert 25: .\"
26: .Dd January 17, 2003
27: .Dt LESS 1
28: .Os
29: .Sh NAME
30: .Nm less , more
31: .Nd view files on a crt
32: .Sh SYNOPSIS
33: .Nm less No | Nm more
1.6 ! jmc 34: .Fl \&?
1.1 millert 35: .Nm less No | Nm more
36: .Fl -help
37: .Nm less No | Nm more
38: .Fl V
39: .Nm less No | Nm more
40: .Fl -version
41: .Nm less No | Nm more
42: .Bk -words
43: .Op Fl Oo Cm + Oc Ns Cm aBcCdeEfFgGiIJLmMnNqQrRsSuUVwWX~
44: .Op Fl b Ar space
45: .Op Fl h Ar lines
46: .Op Fl j Ar line
47: .Op Fl k Ar keyfile
48: .Op Fl o | O Ar logfile
49: .Op Fl p Ar pattern
50: .Op Fl P Ar prompt
51: .Op Fl t Ar tag
52: .Op Fl T Ar tagsfile
53: .Op Fl x Ar tab,...
54: .Op Fl y Ar lines
55: .Op Fl Oo Cm z Oc Ar \ \&lines
56: .Op Fl # Ar shift
57: .Xo Oo Cm \+ Ns Oo Ns Cm \+ Ns
58: .Oc Ar cmd
59: .Oc
60: .Xc
61: .Op Fl -
62: .Op Ar filename ...
63: .Ek
64: .Pp
65: .\" (See the
66: .\" .Sx OPTIONS
67: .\" section for alternate option syntax with long option names.)
68: .Sh DESCRIPTION
69: .Nm
70: is a program similar to the traditional
71: .Xr more 1 ,
72: but which allows backward movement in the file as well as forward movement.
73: Also,
74: .Nm
75: does not have to read the entire input file before starting,
76: so with large input files it starts up faster than text editors like
77: .Xr vi 1 .
78: .Nm
79: uses termcap (or terminfo on some systems),
80: so it can run on a variety of terminals.
81: There is even limited support for hardcopy terminals.
82: (On a hardcopy terminal, lines which should be printed at the top
83: of the screen are prefixed with a caret.)
84: .Pp
85: This version of
86: .Nm
87: also acts as
88: .Xr more 1
89: if it is called as
90: .Nm more .
91: In this mode, the differences are in the prompt and that
92: .Nm more
93: exits by default when it gets to the end of the file.
94: Commands are based on both traditional
95: .Nm more
96: and
97: .Xr vi 1 .
98: Commands may be preceded by a decimal number,
99: called N in the descriptions below.
100: The number is used by some commands, as indicated.
101: .Sh COMMANDS
102: In the following descriptions, ^X means control-X.
103: ESC stands for the ESCAPE key; for example ESC-v means the
104: two character sequence "ESCAPE", then "v".
105: .Bl -tag -width XXXX
106: .It Ic h | H
107: Help: display a summary of these commands.
108: If you forget all the other commands, remember this one.
109: .It Ic SPACE | ^V | f | ^F
110: Scroll forward N lines, default one window (see option -z below).
111: If N is more than the screen size, only the final screenful is displayed.
112: Warning: some systems use ^V as a special literalization character.
113: .It Ic z
114: Like SPACE, but if N is specified, it becomes the new window size.
115: .It Ic ESC-SPACE
116: Like SPACE, but scrolls a full screensful, even if it reaches
117: end-of-file in the process.
118: .It Xo
119: .Ic RETURN No \&| Ic ^N No \&|
120: .Ic e No \&| Ic ^E No \&|
121: .Ic j No \&| Ic ^J
122: .Xc
123: Scroll forward N lines, default 1.
124: The entire N lines are displayed, even if N is more than the screen size.
125: .It Ic d | ^D
126: Scroll forward N lines, default one half of the screen size.
127: If N is specified, it becomes the new default for subsequent d and u commands.
128: .It Ic b | ^B | ESC-v
129: Scroll backward N lines, default one window (see option -z below).
130: If N is more than the screen size, only the final screenful is displayed.
131: .It Ic w
132: Like ESC-v, but if N is specified, it becomes the new window size.
133: .It Xo
134: .Ic y No \&| Ic ^Y No \&|
135: .Ic ^P No \&| Ic k No \&|
136: .Ic ^K
137: .Xc
138: Scroll backward N lines, default 1.
139: The entire N lines are displayed, even if N is more than the screen size.
140: Warning: some systems use ^Y as a special job control character.
141: .It Ic u | ^U
142: Scroll backward N lines, default one half of the screen size.
143: If N is specified, it becomes the new default for subsequent d and u commands.
144: .It Ic ESC-) | RIGHTARROW
145: Scroll horizontally right N characters, default half the screen width
146: (see the -# option).
147: If a number N is specified, it becomes the default for future
148: RIGHTARROW and LEFTARROW commands.
149: While the text is scrolled, it acts as though the -S option (chop lines)
150: were in effect.
151: .It Ic ESC-( | LEFTARROW
152: Scroll horizontally left N
153: characters, default half the screen width (see the -# option).
154: If a number N is specified, it becomes the default for future
155: RIGHTARROW and LEFTARROW commands.
156: .It Ic r | ^R | ^L
157: Repaint the screen.
158: .It Ic R
159: Repaint the screen, discarding any buffered input.
160: Useful if the file is changing while it is being viewed.
161: .It Ic F
162: Scroll forward, and keep trying to read when the end of file is reached.
163: Normally this command would be used when already at the end of the file.
164: It is a way to monitor the tail of a file which is growing
165: while it is being viewed.
166: (The behavior is similar to the "tail -f" command.)
167: .It Ic g | < | ESC-<
168: Go to line N in the file, default 1 (beginning of file).
169: (Warning: this may be slow if N is large.)
170: .It Ic G | > | ESC->
171: Go to line N in the file, default the end of the file.
172: (Warning: this may be slow if N is large,
173: or if N is not specified and standard input, rather than a file,
174: is being read.)
175: .It Ic p | %
176: Go to a position N percent into the file.
177: N should be between 0 and 100.
178: .It Ic {
179: If a left curly bracket appears in the top line displayed
180: on the screen, the { command will go to the matching right curly bracket.
181: The matching right curly bracket is positioned on the bottom
182: line of the screen.
183: If there is more than one left curly bracket on the top line, a number N
184: may be used to specify the N-th bracket on the line.
185: .It Ic }
186: If a right curly bracket appears in the bottom line displayed on the screen,
187: the } command will go to the matching left curly bracket.
188: The matching left curly bracket is positioned on the top
189: line of the screen.
190: If there is more than one right curly bracket on the top line,
191: a number N may be used to specify the N-th bracket on the line.
192: .It Ic \&(
193: Like {, but applies to parentheses rather than curly brackets.
194: .It Ic \&)
195: Like }, but applies to parentheses rather than curly brackets.
196: .It Ic \&[
197: Like {, but applies to square brackets rather than curly brackets.
198: .It Ic \&]
199: Like }, but applies to square brackets rather than curly brackets.
200: .It Ic ESC-^F
201: Followed by two characters, acts like {,
202: but uses the two characters as open and close brackets, respectively.
203: For example, "ESC ^F < >" could be used to
204: go forward to the > which matches the < in the top displayed line.
205: .It Ic ESC-^B
206: Followed by two characters, acts like },
207: but uses the two characters as open and close brackets, respectively.
208: For example, "ESC ^B < >" could be used to
209: go backward to the < which matches the > in the bottom displayed line.
210: .It Ic m
211: Followed by any lowercase letter, marks the current position with that letter.
212: .It Ic '
213: (Single quote.)
214: Followed by any lowercase letter, returns to the position which
215: was previously marked with that letter.
216: Followed by another single quote, returns to the position at
217: which the last "large" movement command was executed.
218: Followed by a ^ or $, jumps to the beginning or end of the file respectively.
219: Marks are preserved when a new file is examined,
220: so the ' command can be used to switch between input files.
221: .It Ic ^X^X
222: Same as single quote.
223: .It Ic /pattern
224: Search forward in the file for the N-th line containing the pattern.
225: N defaults to 1.
226: The pattern is a regular expression, as recognized by
227: .Xr ed 1 .
228: The search starts at the second line displayed
229: (but see the -a and -j options, which change this).
230: .Pp
231: Certain characters are special if entered at the beginning of the pattern;
232: they modify the type of search rather than become part of the pattern:
233: .Bl -tag -width Ds
1.6 ! jmc 234: .It Ic ^N | \&!
1.1 millert 235: Search for lines which do NOT match the pattern.
236: .It Ic ^E | *
237: Search multiple files.
238: That is, if the search reaches the END of the current file
239: without finding a match,
240: the search continues in the next file in the command line list.
241: .It Ic ^F | @
242: Begin the search at the first line of the FIRST file
243: in the command line list,
244: regardless of what is currently displayed on the screen
245: or the settings of the -a or -j options.
246: .It Ic ^K
247: Highlight any text which matches the pattern on the current screen,
248: but don't move to the first match (KEEP current position).
249: .It Ic ^R
250: Don't interpret regular expression metacharacters;
251: that is, do a simple textual comparison.
252: .El
253: .It Ic ?pattern
254: Search backward in the file for the N-th line containing the pattern.
255: The search starts at the line immediately before the top line displayed.
256: .Pp
257: Certain characters are special, as in the / command:
258: .Bl -tag -width Ds
1.6 ! jmc 259: .It Ic ^N | \&!
1.1 millert 260: Search for lines which do NOT match the pattern.
261: .It Ic ^E | *
262: Search multiple files.
263: That is, if the search reaches the beginning of the current file
264: without finding a match,
265: the search continues in the previous file in the command line list.
266: .It Ic ^F | @
267: Begin the search at the last line of the last file
268: in the command line list,
269: regardless of what is currently displayed on the screen
270: or the settings of the -a or -j options.
271: .It Ic ^K
272: As in forward searches.
273: .It Ic ^R
274: As in forward searches.
275: .El
276: .It Ic ESC-/pattern
277: Same as "/*".
278: .It Ic ESC-?pattern
279: Same as "?*".
280: .It Ic n
281: Repeat previous search, for N-th line containing the last pattern.
282: If the previous search was modified by ^N, the search is made for the
283: N-th line NOT containing the pattern.
284: If the previous search was modified by ^E, the search continues
285: in the next (or previous) file if not satisfied in the current file.
286: If the previous search was modified by ^R, the search is done
287: without using regular expressions.
288: There is no effect if the previous search was modified by ^F or ^K.
289: .It Ic N
290: Repeat previous search, but in the reverse direction.
291: .It Ic ESC-n
292: Repeat previous search, but crossing file boundaries.
293: The effect is as if the previous search were modified by *.
294: .It Ic ESC-N
295: Repeat previous search, but in the reverse direction
296: and crossing file boundaries.
297: .It Ic ESC-u
298: Undo search highlighting.
299: Turn off highlighting of strings matching the current search pattern.
300: If highlighting is already off because of a previous ESC-u command,
301: turn highlighting back on.
302: Any search command will also turn highlighting back on.
303: (Highlighting can also be disabled by toggling the -G option;
304: in that case search commands do not turn highlighting back on.)
305: .It Ic :e Op Ar filename
306: Examine a new file.
307: If the filename is missing, the "current" file (see the :n and :p commands
308: below) from the list of files in the command line is re-examined.
309: A percent sign (%) in the filename is replaced by the name of the
310: current file.
311: A pound sign (#) is replaced by the name of the previously examined file.
312: However, two consecutive percent signs are simply
313: replaced with a single percent sign.
314: This allows you to enter a filename that contains a percent sign
315: in the name.
316: Similarly, two consecutive pound signs are replaced with a single pound sign.
317: The filename is inserted into the command line list of files
318: so that it can be seen by subsequent :n and :p commands.
319: If the filename consists of several files, they are all inserted into
320: the list of files and the first one is examined.
321: If the filename contains one or more spaces,
322: the entire filename should be enclosed in double quotes
323: (also see the -" option).
324: .It Ic ^X^V | E
325: Same as :e.
326: Warning: some systems use ^V as a special literalization character.
327: On such systems, you may not be able to use ^V.
328: .It Ic :n
329: Examine the next file (from the list of files given in the command line).
330: If a number N is specified, the N-th next file is examined.
331: .It Ic :p
332: Examine the previous file in the command line list.
333: If a number N is specified, the N-th previous file is examined.
334: .It Ic :t
335: Go to the specified tag.
336: .It Ic :x
337: Examine the first file in the command line list.
338: If a number N is specified, the N-th file in the list is examined.
339: .It Ic :d
340: Remove the current file from the list of files.
341: .It Ic t
342: Go to the next tag, if there were more than one matches for the current tag.
343: See the \-t option for more details about tags.
344: .It Ic T
345: Go to the previous tag, if there were more than one matches for the current tag.
346: .It Ic = | ^G | :f
347: Prints some information about the file being viewed, including its name
348: and the line number and byte offset of the bottom line being displayed.
349: If possible, it also prints the length of the file,
350: the number of lines in the file
351: and the percent of the file above the last displayed line.
352: .It Ic \-
353: Followed by one of the command line option letters (see
354: .Sx OPTIONS
355: below),
356: this will change the setting of that option
357: and print a message describing the new setting.
358: If a ^P (CONTROL-P) is entered immediately after the dash,
359: the setting of the option is changed but no message is printed.
360: If the option letter has a numeric value (such as -b or -h),
361: or a string value (such as -P or -t),
362: a new value may be entered after the option letter.
363: If no new value is entered, a message describing
364: the current setting is printed and nothing is changed.
365: .It Ic \-\-
366: Like the \- command, but takes a long option name (see
367: .Sx OPTIONS
368: below)
369: rather than a single option letter.
370: You must press RETURN after typing the option name.
371: A ^P immediately after the second dash suppresses printing of a
372: message describing the new setting, as in the \- command.
373: .It Ic \-+
374: Followed by one of the command line option letters this will reset the
375: option to its default setting and print a message describing the new setting.
376: (The "\-+X" command does the same thing as "\-+X" on the command line.)
377: This does not work for string-valued options.
378: .It Ic \-\-+
379: Like the \-+ command, but takes a long option name
380: rather than a single option letter.
381: .It Ic \-!
382: Followed by one of the command line option letters, this will reset the
383: option to the "opposite" of its default setting and print a message
384: describing the new setting.
385: This does not work for numeric or string-valued options.
386: .It Ic \-\-!
387: Like the \-! command, but takes a long option name
388: rather than a single option letter.
389: .It Ic _
390: (Underscore.)
391: Followed by one of the command line option letters,
392: this will print a message describing the current setting of that option.
393: The setting of the option is not changed.
394: .It Ic __
395: (Double underscore.)
396: Like the _ (underscore) command, but takes a long option name
397: rather than a single option letter.
398: You must press RETURN after typing the option name.
399: .It Ic +cmd
400: Causes the specified cmd to be executed each time a new file is examined.
401: For example, +G causes
402: .Nm
403: to initially display each file starting at the end rather than the beginning.
404: .It Ic V
405: Prints the version number of
406: .Nm
407: being run.
408: .It Xo
409: .Ic q No \&| Ic Q No \&|
410: .Ic :q No \&| Ic :Q No \&|
411: .Ic ZZ
412: .Xc
413: Exits
414: .Nm less .
415: .El
416: .Pp
417: The following
418: four
419: commands may or may not be valid, depending on your particular installation.
420: .Bl -tag -width XXXX
421: .It Ic v
422: Invokes an editor to edit the current file being viewed.
423: The editor is taken from the environment variable
424: .Ev VISUAL ,
425: if defined,
426: or
427: .Ev EDITOR
428: if
429: .Ev VISUAL
430: is not defined,
431: or defaults to "vi" if neither
432: .Ev VISUAL
433: nor
434: .Ev EDITOR
435: is defined.
436: See also the discussion of LESSEDIT under the section on
437: .Sx PROMPTS
438: below.
1.6 ! jmc 439: .It Ic \&! Ar shell-command
1.1 millert 440: Invokes a shell to run the shell-command given.
441: A percent sign (%) in the command is replaced by the name of the current file.
442: A pound sign (#) is replaced by the name of the previously examined file.
443: "!!" repeats the last shell command.
444: "!" with no shell command simply invokes a shell.
445: The shell is taken from the environment variable
446: .Ev SHELL ,
447: or defaults to "sh".
448: .\" On MS-DOS and OS/2 systems, the shell is the normal command processor.
449: .It Ic \&| <m> Ar shell-command
450: <m> represents any mark letter.
451: Pipes a section of the input file to the given shell command.
452: The section of the file to be piped is between the first line on
453: the current screen and the position marked by the letter.
454: <m> may also be ^ or $ to indicate beginning or end of file respectively.
455: If <m> is . or newline, the current screen is piped.
456: .It Ic s Ar filename
457: Save the input to a file.
458: This only works if the input is a pipe, not an ordinary file.
459: .El
460: .Sh OPTIONS
461: Command line options are described below.
462: Most options may be changed while
463: .Nm
464: is running, via the "\-" command.
465: .Pp
466: Most options may be given in one of two forms:
467: either a dash followed by a single letter, or two dashes followed by a
468: long option name.
469: A long option name may be abbreviated as long as the abbreviation is
470: unambiguous.
471: For example, --quit-at-eof may be abbreviated --quit, but not
472: --qui, since both --quit-at-eof and --quiet begin with --qui.
473: Some long option names are in uppercase, such as --QUIT-AT-EOF, as
474: distinct from --quit-at-eof.
475: Such option names need only have their first letter capitalized;
476: the remainder of the name may be in either case.
477: For example, --Quit-at-eof is equivalent to --QUIT-AT-EOF.
478: .Pp
479: Options are also taken from the environment variable
480: .Ev LESS
481: if the command is
482: .Nm less ,
483: or from the environment variable
484: .Ev MORE
485: if the command is
486: .Nm more .
487: For example, to avoid typing "less -options ..." each time
488: .Nm
489: is invoked, you might tell
490: .Xr csh 1 :
491: .Pp
492: .Dl setenv LESS "-options"
493: .Pp
494: or if you use
495: .Xr sh 1 :
496: .Pp
497: .Dl LESS="-options"; export LESS
498: .Pp
499: .\" On MS-DOS, you don't need the quotes, but you should replace any
500: .\" percent signs in the options string by double percent signs.
501: .\" .Pp
502: The environment variable is parsed before the command line,
503: so command line options override the
504: .Ev LESS
505: environment variable.
506: If an option appears in the
507: .Ev LESS
508: variable, it can be reset to its default value on the command line by
509: beginning the command line option with "\-+".
510: .Pp
511: For options like -P which take a following string,
512: a dollar sign ($) must be used to signal the end of the string.
513: For example, to separate a prompt value from any other options
514: with dollar sign between them:
515: .Pp
516: .Dl LESS="-Ps--More--$-C -e"
517: .Bl -tag -width XXXX
1.6 ! jmc 518: .It Fl \&? | -help
1.1 millert 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: .Bl -tag -width Ds
989: .It LEFTARROW [ ESC-h ]
990: Move the cursor one space to the left.
991: .It RIGHTARROW [ ESC-l ]
992: Move the cursor one space to the right.
993: .It ^LEFTARROW [ ESC-b or ESC-LEFTARROW ]
994: (That is, CONTROL and LEFTARROW simultaneously.)
995: Move the cursor one word to the left.
996: .It ^RIGHTARROW [ ESC-w or ESC-RIGHTARROW ]
997: (That is, CONTROL and RIGHTARROW simultaneously.)
998: Move the cursor one word to the right.
999: .It HOME [ ESC-0 ]
1000: Move the cursor to the beginning of the line.
1001: .It END [ ESC-$ ]
1002: Move the cursor to the end of the line.
1003: .It BACKSPACE
1004: Delete the character to the left of the cursor,
1005: or cancel the command if the command line is empty.
1006: .It DELETE or [ ESC-x ]
1007: Delete the character under the cursor.
1008: .It ^BACKSPACE [ ESC-BACKSPACE ]
1009: (That is, CONTROL and BACKSPACE simultaneously.)
1010: Delete the word to the left of the cursor.
1011: .It ^DELETE [ ESC-X or ESC-DELETE ]
1012: (That is, CONTROL and DELETE simultaneously.)
1013: Delete the word under the cursor.
1014: .It UPARROW [ ESC-k ]
1015: Retrieve the previous command line.
1016: .It DOWNARROW [ ESC-j ]
1017: Retrieve the next command line.
1018: .It TAB
1019: Complete the partial filename to the left of the cursor.
1020: If it matches more than one filename, the first match
1021: is entered into the command line.
1022: Repeated TABs will cycle through the other matching filenames.
1023: If the completed filename is a directory, a "/" is appended to the filename.
1024: .\" (On MS-DOS systems, a "\e" is appended.)
1025: The environment variable
1026: .Ev LESSSEPARATOR
1027: can be used to specify a different character to append to a directory name.
1028: .It BACKTAB [ ESC-TAB ]
1029: Like TAB, but cycles in the reverse direction through the matching filenames.
1030: .It ^L
1031: Complete the partial filename to the left of the cursor.
1032: If it matches more than one filename, all matches are entered into
1033: the command line (if they fit).
1034: .\" .It ^U (Unix and OS/2) or ESC (MS-DOS)
1035: .It ^U
1036: Delete the entire command line,
1037: or cancel the command if the command line is empty.
1038: If you have changed your line-kill character to something
1039: other than ^U, that character is used instead of ^U.
1040: .El
1041: .Sh KEY BINDINGS
1042: You may define your own
1043: .Nm
1044: commands by using the program
1045: .Xr lesskey 1
1046: to create a lesskey file.
1047: This file specifies a set of command keys and an action
1048: associated with each key.
1049: You may also use lesskey
1050: to change the line-editing keys (see
1051: .Sx LINE EDITING ) ,
1052: and to set environment variables.
1053: If the environment variable
1054: .Ev LESSKEY
1055: is set,
1056: .Nm
1057: uses that as the name of the lesskey file.
1058: Otherwise,
1059: .Nm
1060: looks for a lesskey file called "$HOME/.less".
1061: .\" On MS-DOS and Windows systems,
1062: .\" .I less
1063: .\" looks for a lesskey file called "$HOME/_less", and if it is not found there,
1064: .\" then looks for a lesskey file called "_less" in any directory specified
1065: .\" in the PATH environment variable.
1066: .\" On OS/2 systems,
1067: .\" .I less
1068: .\" looks for a lesskey file called "$HOME/less.ini", and if it is not found,
1069: .\" then looks for a lesskey file called "less.ini" in any directory specified
1070: .\" in the INIT environment variable, and if it not found there,
1071: .\" then looks for a lesskey file called "less.ini" in any directory specified
1072: .\" in the PATH environment variable.
1073: See the
1074: .Xr lesskey 1
1075: manual page for more details.
1076: .Pp
1077: A system-wide lesskey file may also be set up to provide key bindings.
1078: If a key is defined in both a local lesskey file and in the
1079: system-wide file, key bindings in the local file take precedence over
1080: those in the system-wide file.
1081: If the environment variable
1082: .Ev LESSKEY_SYSTEM
1083: is set,
1084: .Nm
1085: uses that as the name of the system-wide lesskey file.
1086: Otherwise,
1087: .Nm
1088: looks in a standard place for the system-wide lesskey file:
1089: On
1090: .Ox ,
1091: the system-wide lesskey file is
1092: .Pa /etc/sysless .
1093: .\" On Unix systems, the system-wide lesskey file is /usr/local/etc/sysless.
1094: .\" (However, if
1095: .\" .Nm less
1096: .\" was built with a different sysconf directory than /usr/local/etc,
1097: .\" that directory is where the sysless file is found.)
1098: .\" On MS-DOS and Windows systems, the system-wide lesskey file is c:\e_sysless.
1099: .\" On OS/2 systems, the system-wide lesskey file is c:\esysless.ini.
1100: .Sh INPUT PREPROCESSOR
1101: You may define an "input preprocessor" for
1102: .Nm less .
1103: Before
1104: .Nm less
1105: opens a file, it first gives your input preprocessor a chance to modify the
1106: way the contents of the file are displayed.
1107: An input preprocessor is simply an executable program (or shell script),
1108: which writes the contents of the file to a different file,
1109: called the replacement file.
1110: The contents of the replacement file are then displayed
1111: in place of the contents of the original file.
1112: However, it will appear to the user as if the original file is opened;
1113: that is,
1114: .Nm less
1115: will display the original filename as the name of the current file.
1116: .Pp
1117: An input preprocessor receives one command line argument, the original filename,
1118: as entered by the user.
1119: It should create the replacement file, and when finished
1120: print the name of the replacement file to its standard output.
1121: If the input preprocessor does not output a replacement filename,
1122: .Nm
1123: uses the original file, as normal.
1124: The input preprocessor is not called when viewing standard input.
1125: To set up an input preprocessor, set the
1126: .Ev LESSOPEN
1127: environment variable to a command line which will invoke your
1128: input preprocessor.
1129: This command line should include one occurrence of the string "%s",
1130: which will be replaced by the filename
1131: when the input preprocessor command is invoked.
1132: .Pp
1133: When
1134: .Nm
1135: closes a file opened in such a way, it will call another program,
1136: called the input postprocessor,
1137: which may perform any desired clean-up action (such as deleting the
1138: replacement file created by
1139: .Ev LESSOPEN ) .
1140: This program receives two command line arguments, the original filename
1141: as entered by the user, and the name of the replacement file.
1142: To set up an input postprocessor, set the
1143: .Ev LESSCLOSE
1144: environment variable to a command line which will invoke your
1145: input postprocessor.
1146: It may include two occurrences of the string "%s";
1147: the first is replaced with the original name of the file and the second
1148: with the name of the replacement file, which was output by
1149: .Ev LESSOPEN .
1150: .Pp
1151: For example, these two scripts will allow you
1152: to keep files in compressed format, but still let
1153: .Nm
1154: view them directly:
1155: .Pp
1156: lessopen.sh:
1157: .Bd -literal -offset indent
1158: #! /bin/sh
1159: case "$1" in
1160: *.Z) uncompress -c $1 >/tmp/less.$$ 2>/dev/null
1161: if [ -s /tmp/less.$$ ]; then
1162: echo /tmp/less.$$
1163: else
1164: rm -f /tmp/less.$$
1165: fi
1166: ;;
1167: esac
1168: .Ed
1169: .Pp
1170: lessclose.sh:
1171: .Bd -literal -offset indent
1172: #! /bin/sh
1173: rm $2
1174: .Ed
1175: .Pp
1176: To use these scripts, put them both where they can be executed and
1177: set LESSOPEN="lessopen.sh\ %s", and LESSCLOSE="lessclose.sh\ %s\ %s".
1178: More complex LESSOPEN and LESSCLOSE scripts may be written
1179: to accept other types of compressed files, and so on.
1180: .Pp
1181: It is also possible to set up an input preprocessor to
1182: pipe the file data directly to
1183: .Nm less ,
1184: rather than putting the data into a replacement file.
1185: This avoids the need to decompress the entire file before starting to view it.
1186: An input preprocessor that works this way is called an input pipe.
1187: An input pipe, instead of writing the name of a replacement file on
1188: its standard output,
1189: writes the entire contents of the replacement file on its standard output.
1190: If the input pipe does not write any characters on its standard output,
1191: then there is no replacement file and
1192: .Nm
1193: uses the original file, as normal.
1194: To use an input pipe, make the first character in the
1195: .Ev LESSOPEN
1196: environment variable a vertical bar (|) to signify that the
1197: input preprocessor is an input pipe.
1198: .Pp
1199: For example, this script will work like the previous example scripts:
1200: .Pp
1201: lesspipe.sh:
1202: .Bd -literal -offset indent
1203: #! /bin/sh
1204: case "$1" in
1205: *.Z) uncompress -c $1 2>/dev/null
1206: ;;
1207: esac
1208: .Ed
1209: .Pp
1210: To use this script, put it where it can be executed and set
1211: LESSOPEN="|lesspipe.sh %s".
1212: When an input pipe is used, a LESSCLOSE postprocessor can be used,
1213: but it is usually not necessary since there is no replacement file to clean up.
1214: In this case, the replacement file name passed to the LESSCLOSE
1215: postprocessor is "-".
1216: .Sh NATIONAL CHARACTER SETS
1217: There are three types of characters in the input file:
1218: .Bl -tag -width "control characters"
1219: .It normal characters
1220: Can be displayed directly to the screen.
1221: .It control characters
1222: Should not be displayed directly, but are expected to be found
1223: in ordinary text files (such as backspace and tab).
1224: .It binary characters
1225: Should not be displayed directly and are not expected to be found
1226: in text files.
1227: .El
1228: .Pp
1229: A "character set" is simply a description of which characters are to
1230: be considered normal, control, and binary.
1231: The
1232: .Ev LESSCHARSET
1233: environment variable may be used to select a character set.
1234: Possible values for
1235: .Ev LESSCHARSET
1236: are:
1237: .Bl -tag -width "IBM-1047"
1238: .It ascii
1239: BS, TAB, NL, CR, and formfeed are control characters,
1240: all chars with values between 32 and 126 are normal,
1241: and all others are binary.
1242: .It iso8859
1243: Selects an ISO 8859 character set.
1244: This is the same as ASCII, except characters between 160 and 255 are
1245: treated as normal characters.
1246: .It latin1
1247: Same as iso8859.
1248: .It latin9
1249: Same as iso8859.
1250: .It dos
1251: Selects a character set appropriate for MS-DOS.
1252: .It ebcdic
1253: Selects an EBCDIC character set.
1254: .It IBM-1047
1255: Selects an EBCDIC character set used by OS/390 Unix Services.
1256: This is the EBCDIC analogue of latin1.
1257: You get similar results by setting either LESSCHARSET=IBM-1047 or
1258: LC_CTYPE=en_US in your environment.
1259: .It koi8-r
1260: Selects a Russian character set.
1261: .It next
1262: Selects a character set appropriate for NeXT computers.
1263: .It utf-8
1264: Selects the UTF-8 encoding of the ISO 10646 character set.
1265: .El
1266: .Pp
1267: In special cases, it may be desired to tailor
1268: .Nm
1269: to use a character set other than the ones definable by LESSCHARSET.
1270: In this case, the environment variable
1271: .Ev LESSCHARDEF
1272: can be used to define a character set.
1273: It should be set to a string where each character in the string represents
1274: one character in the character set.
1275: The character "." is used for a normal character, "c" for control,
1276: and "b" for binary.
1277: A decimal number may be used for repetition.
1278: For example, "bccc4b." would mean character 0 is binary,
1279: 1, 2 and 3 are control, 4, 5, 6 and 7 are binary, and 8 is normal.
1280: All characters after the last are taken to be the same as the last,
1281: so characters 9 through 255 would be normal.
1282: (This is an example, and does not necessarily
1283: represent any real character set.)
1284: .Pp
1285: This table shows the value of LESSCHARDEF which is equivalent
1286: to each of the possible values for LESSCHARSET:
1287: .Bd -literal -offset indent
1288: ascii 8bcccbcc18b95.b
1289: dos 8bcccbcc12bc5b95.b.
1290: ebcdic 5bc6bcc7bcc41b.9b7.9b5.b..8b6.10b6.b9.7b
1291: 9.8b8.17b3.3b9.7b9.8b8.6b10.b.b.b.
1292: IBM-1047 4cbcbc3b9cbccbccbb4c6bcc5b3cbbc4bc4bccbc
1293: 191.b
1294: iso8859 8bcccbcc18b95.33b.
1295: koi8-r 8bcccbcc18b95.b128.
1296: latin1 8bcccbcc18b95.33b.
1297: next 8bcccbcc18b95.bb125.bb
1298: .Ed
1299: .Pp
1300: If neither LESSCHARSET nor LESSCHARDEF is set,
1301: but the string "UTF-8" is found in the
1302: .Ev LC_ALL , LC_TYPE
1303: or
1304: .Ev LANG
1305: environment variables, then the default character set is utf-8.
1306: .Pp
1307: If that string is not found, but your system supports the
1308: setlocale interface,
1309: .Nm
1310: will use setlocale to determine the character set.
1311: setlocale is controlled by setting the
1312: .Ev LANG
1313: or
1314: .Ev LC_CTYPE
1315: environment variables.
1316: .Pp
1317: Finally, if the
1318: setlocale interface is also not available, the default character set is latin1.
1319: .Pp
1320: Control and binary characters are displayed in standout (reverse video).
1321: Each such character is displayed in caret notation if possible
1322: (e.g. ^A for control-A).
1323: Caret notation is used only if inverting the 0100 bit results in a
1324: normal printable character.
1325: Otherwise, the character is displayed as a hex number in angle brackets.
1326: This format can be changed by setting the
1327: .Ev LESSBINFMT
1328: environment variable.
1329: LESSBINFMT may begin with a "*" and one character to select
1330: the display attribute:
1331: "*k" is blinking, "*d" is bold, "*u" is underlined, "*s" is standout,
1332: and "*n" is normal.
1333: If LESSBINFMT does not begin with a "*", normal attribute is assumed.
1334: The remainder of LESSBINFMT is a string which may include one
1335: printf-style escape sequence (a % followed by x, X, o, d, etc.).
1336: For example, if LESSBINFMT is "*u[%x]", binary characters
1337: are displayed in underlined hexadecimal surrounded by brackets.
1338: The default if no LESSBINFMT is specified is "*s<%X>".
1339: .Sh PROMPTS
1340: The -P option allows you to tailor the prompt to your preference.
1341: The string given to the -P option replaces the specified prompt string.
1342: Certain characters in the string are interpreted specially.
1343: The prompt mechanism is rather complicated to provide flexibility,
1344: but the ordinary user need not understand the details of constructing
1345: personalized prompt strings.
1346: .Pp
1347: A percent sign followed by a single character is expanded
1348: according to what the following character is:
1349: .Bl -tag -width Ds
1350: .It %b Ns Ar X
1351: Replaced by the byte offset into the current input file.
1352: The b is followed by a single character (shown as
1353: .Ar X
1354: above) which specifies the line whose byte offset is to be used.
1355: If the character is a "t", the byte offset of the top line in the
1356: display is used,
1357: an "m" means use the middle line,
1358: a "b" means use the bottom line,
1359: a "B" means use the line just after the bottom line,
1360: and a "j" means use the "target" line, as specified by the -j option.
1.4 jmc 1361: .It \&%B
1.1 millert 1362: Replaced by the size of the current input file.
1363: .It %c
1364: Replaced by the column number of the text appearing in the first
1365: column of the screen.
1366: .It %d Ns Ar X
1367: Replaced by the page number of a line in the input file.
1368: The line to be used is determined by the
1369: .Ar X ,
1370: as with the %b option.
1.4 jmc 1371: .It \&%D
1.1 millert 1372: Replaced by the number of pages in the input file,
1373: or equivalently, the page number of the last line in the input file.
1374: .It %E
1375: Replaced by the name of the editor (from the
1376: .Ev VISUAL
1377: environment variable, or the
1378: .Ev EDITOR
1379: environment variable if
1380: .Ev VISUAL
1381: is not defined).
1382: See the discussion of the LESSEDIT feature below.
1383: .It %f
1384: Replaced by the name of the current input file.
1385: .It %i
1386: Replaced by the index of the current file in the list of
1387: input files.
1388: .It %l Ns Ar X
1389: Replaced by the line number of a line in the input file.
1390: The line to be used is determined by the
1391: .Ar X ,
1392: as with the %b option.
1393: .It %L
1394: Replaced by the line number of the last line in the input file.
1395: .It %m
1396: Replaced by the total number of input files.
1397: .It %p Ns Ar X
1398: Replaced by the percent into the current input file, based on byte offsets.
1399: The line used is determined by the
1400: .Ar X ,
1401: as with the %b option.
1.4 jmc 1402: .It \&%P Ns Ar X
1.1 millert 1403: Replaced by the percent into the current input file, based on line numbers.
1404: The line used is determined by the
1405: .Ar X ,
1406: as with the %b option.
1407: .It %s
1408: Same as %B.
1409: .It %t
1410: Causes any trailing spaces to be removed.
1411: Usually used at the end of the string, but may appear anywhere.
1412: .It %x
1413: Replaced by the name of the next input file in the list.
1414: .El
1415: .Pp
1416: If any item is unknown (for example, the file size if input is a pipe),
1417: a question mark is printed instead.
1418: .Pp
1419: The format of the prompt string can be changed depending on certain conditions.
1420: A question mark followed by a single character acts like an "IF":
1421: depending on the following character, a condition is evaluated.
1422: If the condition is true, any characters following the question mark
1423: and condition character, up to a period, are included in the prompt.
1424: If the condition is false, such characters are not included.
1425: A colon appearing between the question mark and the
1426: period can be used to establish an "ELSE": any characters between
1427: the colon and the period are included in the string, if and only if
1428: the IF condition is false.
1429: Condition characters (which follow a question mark) may be:
1430: .Bl -tag -width Ds
1431: .It ?a
1432: True if any characters have been included in the prompt so far.
1433: .It ?b Ns Ar X
1434: True if the byte offset of the specified line is known.
1435: .It ?B
1436: True if the size of the current input file is known.
1437: .It ?c
1438: True if the text is horizontally shifted (%c is not zero).
1439: .It ?d Ns Ar X
1440: True if the page number of the specified line is known.
1441: .It ?e
1442: True if at end-of-file.
1443: .It ?f
1444: True if there is an input filename
1445: (that is, if input is not a pipe).
1446: .It ?l Ns Ar X
1447: True if the line number of the specified line is known.
1448: .It ?L
1449: True if the line number of the last line in the file is known.
1450: .It ?m
1451: True if there is more than one input file.
1452: .It ?n
1453: True if this is the first prompt in a new input file.
1454: .It ?p Ns Ar X
1455: True if the percent into the current input file, based on byte offsets,
1456: of the specified line is known.
1457: .It ?P Ns Ar X
1458: True if the percent into the current input file, based on line numbers,
1459: of the specified line is known.
1460: .It ?s
1461: Same as "?B".
1462: .It ?x
1463: True if there is a next input file
1464: (that is, if the current input file is not the last one).
1465: .El
1466: .Pp
1467: Any characters other than the special ones
1468: (question mark, colon, period, percent, and backslash)
1469: become literally part of the prompt.
1470: Any of the special characters may be included in the prompt literally
1471: by preceding it with a backslash.
1472: .Pp
1473: Some examples:
1474: .Pp
1475: .Dl ?f%f:Standard input.
1476: .Pp
1477: This prompt prints the filename, if known;
1478: otherwise the string "Standard input".
1479: .Pp
1480: .Dl ?f%f .?ltLine %lt:?pt%pt\e%:?btByte %bt:-...
1481: .Pp
1482: This prompt would print the filename, if known.
1483: The filename is followed by the line number, if known,
1484: otherwise the percent if known, otherwise the byte offset if known.
1485: Otherwise, a dash is printed.
1486: Notice how each question mark has a matching period,
1487: and how the % after the %pt
1488: is included literally by escaping it with a backslash.
1489: .Pp
1490: .Dl ?n?f%f\ .?m(file\ %i\ of\ %m)\ ..?e(END)\ ?x-\ Next\e:\ %x..%t
1491: .Pp
1492: This prints the filename if this is the first prompt in a file,
1493: followed by the "file N of N" message if there is more
1494: than one input file.
1495: Then, if we are at end-of-file, the string "(END)" is printed
1496: followed by the name of the next file, if there is one.
1497: Finally, any trailing spaces are truncated.
1498: This is the default prompt.
1499: For reference, here are the defaults for
1500: the other two prompts (-m and -M respectively).
1501: Each is broken into two lines here for readability only.
1502: .Bd -literal -offset indent
1503: ?n?f%f\ .?m(file\ %i\ of\ %m)\ ..?e(END)\ ?x-\ Next\e:\ %x.:
1504: ?pB%pB\e%:byte\ %bB?s/%s...%t
1505:
1506: ?f%f\ .?n?m(file\ %i\ of\ %m)\ ..?ltlines\ %lt-%lb?L/%L.\ :
1507: byte\ %bB?s/%s.\ .?e(END)\ ?x-\ Next\e:\ %x.:?pB%pB\e%..%t
1508: .Ed
1509: .Pp
1510: And here is the default message produced by the = command:
1511: .Bd -literal -offset indent
1512: ?f%f\ .?m(file\ %i\ of\ %m)\ .?ltlines\ %lt-%lb?L/%L.\ .
1513: byte\ %bB?s/%s.\ ?e(END)\ :?pB%pB\e%..%t
1514: .Ed
1515: .Pp
1516: The prompt expansion features are also used for another purpose:
1517: if an environment variable
1518: .Ev LESSEDIT
1519: is defined, it is used as the command to be executed when the v command
1520: is invoked.
1521: The LESSEDIT string is expanded in the same way as the prompt strings.
1522: The default value for LESSEDIT is:
1523: .Pp
1524: .Dl %E\ ?lm+%lm.\ %f
1525: .Pp
1526: Note that this expands to the editor name, followed by a + and the
1527: line number, followed by the file name.
1528: If your editor does not accept the "+linenumber" syntax, or has other
1529: differences in invocation syntax, the
1530: .Ev LESSEDIT
1531: variable can be changed to modify this default.
1532: .Sh SECURITY
1533: When the environment variable
1534: .Ev LESSSECURE
1535: is set to 1,
1536: .Nm
1537: runs in a "secure" mode.
1538: This means these features are disabled:
1539: .Bl -tag -width Ds
1.6 ! jmc 1540: .It \&!
1.1 millert 1541: The shell command.
1542: .It |
1543: The pipe command.
1544: .It :e
1545: The examine command.
1546: .It v
1547: The editing command.
1548: .It s -o
1549: Log files.
1550: .It -k
1551: Use of lesskey files.
1552: .It -t
1553: Use of tags files.
1554: .It " "
1555: Metacharacters in filenames, such as "*".
1556: .It " "
1557: Filename completion (TAB, ^L).
1558: .El
1559: .Pp
1560: Less can also be compiled to be permanently in "secure" mode.
1.3 jmc 1561: .Sh ENVIRONMENT
1.1 millert 1562: Environment variables may be specified either in the system environment
1563: as usual, or in a
1564: .Xr lesskey 1
1565: file.
1566: If environment variables are defined in more than one place,
1567: variables defined in a local lesskey file take precedence over
1568: variables defined in the system environment, which take precedence
1569: over variables defined in the system-wide lesskey file.
1570: .Bl -tag -width Ds
1571: .It Ev COLUMNS
1572: Sets the number of columns on the screen.
1573: Takes precedence over the number of columns specified by the TERM variable.
1574: (But if you have a windowing system which supports TIOCGWINSZ or WIOCGETD,
1575: the window system's idea of the screen size takes precedence over the
1576: LINES and COLUMNS environment variables.)
1577: .It Ev EDITOR
1578: The name of the editor (used for the v command).
1579: .It Ev HOME
1580: Name of the user's home directory
1581: (used to find a lesskey file).
1582: .\" .It Ev "HOMEDRIVE, HOMEPATH"
1583: .\" Concatenation of the HOMEDRIVE and HOMEPATH environment variables is
1584: .\" the name of the user's home directory if the HOME variable is not set
1585: .\" (only in the Windows version).
1586: .\" .It Ev INIT
1587: .\" Name of the user's init directory
1588: .\" (used to find a lesskey file on OS/2 systems).
1589: .It Ev LANG
1590: Language for determining the character set.
1591: .It Ev LC_CTYPE
1592: Language for determining the character set.
1593: .It Ev LESS
1594: Options which are passed to
1595: .Nm
1596: automatically.
1597: .It Ev LESSANSIENDCHARS
1598: Characters which are assumed to end an ANSI color escape sequence
1599: (default "m").
1600: .It Ev LESSBINFMT
1601: Format for displaying non-printable, non-control characters.
1602: .It Ev LESSCHARDEF
1603: Defines a character set.
1604: .It Ev LESSCHARSET
1605: Selects a predefined character set.
1606: .It Ev LESSCLOSE
1607: Command line to invoke the (optional) input-postprocessor.
1608: .\" .It Ev LESSECHO
1609: .\" Name of the lessecho program (default "lessecho").
1610: .\" The lessecho program is needed to expand metacharacters, such as * and ?,
1611: .\" in filenames on Unix systems.
1612: .It Ev LESSEDIT
1613: Editor prototype string (used for the v command).
1614: See discussion under
1615: .Sx PROMPTS .
1616: .It Ev LESSGLOBALTAGS
1617: Name of the command used by the -t option to find global tags.
1618: Normally should be set to "global" if your system has the global command.
1619: If not set, global tags are not used.
1620: .It Ev LESSKEY
1621: Name of the default lesskey(1) file.
1622: .It Ev LESSKEY_SYSTEM
1623: Name of the default system-wide lesskey(1) file.
1624: .It Ev LESSMETACHARS
1625: List of characters which are considered "metacharacters" by the shell.
1626: .It Ev LESSMETAESCAPE
1627: Prefix which
1628: .Nm
1629: will add before each metacharacter in a command sent to the shell.
1630: If LESSMETAESCAPE is an empty string, commands containing
1631: metacharacters will not be passed to the shell.
1632: .It Ev LESSOPEN
1633: Command line to invoke the (optional) input-preprocessor.
1634: .It Ev LESSSECURE
1635: Runs less in "secure" mode.
1636: See discussion under
1637: .Sx SECURITY .
1638: .It Ev LESSSEPARATOR
1639: String to be appended to a directory name in filename completion.
1640: .It Ev LINES
1641: Sets the number of lines on the screen.
1642: Takes precedence over the number of lines specified by the TERM variable.
1643: (But if you have a windowing system which supports TIOCGWINSZ or WIOCGETD,
1644: the window system's idea of the screen size takes precedence over the
1645: LINES and COLUMNS environment variables.)
1646: .\" .It Ev PATH
1647: .\" User's search path (used to find a lesskey file
1648: .\" on MS-DOS and OS/2 systems).
1649: .It Ev SHELL
1650: The shell used to execute the ! command, as well as to expand filenames.
1651: .It Ev TERM
1652: The type of terminal on which
1653: .Nm
1654: is being run.
1655: .It Ev VISUAL
1656: The name of the editor (used for the v command).
1657: .El
1658: .Sh SEE ALSO
1659: .Xr lesskey 1
1660: .Sh WARNINGS
1661: The = command and prompts (unless changed by -P)
1662: report the line numbers of the lines at the top and bottom of the screen,
1663: but the byte and percent of the line after the one at the bottom of the screen.
1664: .Pp
1665: If the :e command is used to name more than one file,
1666: and one of the named files has been viewed previously,
1667: the new files may be entered into the list in an unexpected order.
1668: .Pp
1669: On certain older terminals (the so-called "magic cookie" terminals),
1670: search highlighting will cause an erroneous display.
1671: On such terminals, search highlighting is disabled by default
1672: to avoid possible problems.
1673: .Pp
1674: In certain cases, when search highlighting is enabled and
1675: a search pattern begins with a ^,
1676: more text than the matching string may be highlighted.
1677: (This problem does not occur when
1678: .Nm
1679: is compiled to use the POSIX regular expression package.)
1680: .Pp
1681: When viewing text containing ANSI color escape sequences using the -R option,
1682: searching will not find text containing an embedded escape sequence.
1683: Also, search highlighting may change the color of some of the text
1684: which follows the highlighted text.
1685: .Pp
1686: On some systems, setlocale claims that ASCII characters 0 through 31 are
1687: control characters rather than binary characters.
1688: This causes
1689: .Nm
1690: to treat some binary files as ordinary, non-binary files.
1691: To workaround this problem, set the environment variable
1692: .Ev LESSCHARSET
1693: to "ascii" (or whatever character set is appropriate).
1694: .Pp
1695: See
1696: .Pa http://www.greenwoodsoftware.com/less
1697: for the latest list of known bugs in this version of
1698: .Nm less .
1699: .Sh COPYRIGHT
1700: Copyright (C) 2002 Mark Nudelman
1701: .Pp
1.5 millert 1702: Redistribution and use in source and binary forms, with or without
1703: modification, are permitted provided that the following conditions
1704: are met:
1705: .Bl -enum -compact
1706: .It
1707: Redistributions of source code must retain the above copyright
1708: notice, this list of conditions and the following disclaimer.
1709: .It
1710: Redistributions in binary form must reproduce the above copyright
1711: notice in the documentation and/or other materials provided with
1712: the distribution.
1713: .El
1714: .Pp
1715: THIS SOFTWARE IS PROVIDED BY THE AUTHOR
1716: .Dq AS IS
1717: AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1718: IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1719: PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
1720: FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1721: CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
1722: OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
1723: BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
1724: WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
1725: OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
1726: IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1.2 jmc 1727: .Sh AUTHORS
1.3 jmc 1728: .An Mark Nudelman Aq markn@greenwoodsoftware.com
1.1 millert 1729: .br
1730: Send bug reports or comments to the above address or to bug-less@gnu.org.
1731: .br
1732: For more information, see the less homepage at
1733: .Pa http://www.greenwoodsoftware.com/less .