Annotation of src/usr.bin/less/less.nro, Revision 1.3
1.1 etheisen 1: .TH LESS 1
2: .SH NAME
1.2 etheisen 3: less, more \- view files on a crt
1.1 etheisen 4: .SH SYNOPSIS
1.2 etheisen 5: .B "less|more -?"
1.1 etheisen 6: .br
1.2 etheisen 7: .B "less|more -V"
1.1 etheisen 8: .br
1.2 etheisen 9: .B "less|more [-[+]aBcCdeEfgGiImMnNqQrsSuUVwX]"
1.1 etheisen 10: .br
11: .B " [-b \fIbufs\fP] [-h \fIlines\fP] [-j \fIline\fP] [-k \fIkeyfile\fP]"
12: .br
13: .B " [-{oO} \fIlogfile\fP] [-p \fIpattern\fP] [-P \fIprompt\fP] [-t \fItag\fP]"
14: .br
15: .B " [-T \fItagsfile\fP] [-x \fItab\fP] [-y \fIlines\fP] [-[z] \fIlines\fP]"
16: .br
17: .B " [+[+]\fIcmd\fP] [\fIfilename\fP]..."
18:
19: .SH DESCRIPTION
20: .I Less
1.2 etheisen 21: is a program similar to the traditional
1.1 etheisen 22: .I more
23: (1), but which allows backward movement
24: in the file as well as forward movement.
25: Also,
26: .I less
27: does not have to read the entire input file before starting,
28: so with large input files it starts up faster than text editors like
29: .I vi
30: (1).
31: .I Less
32: uses termcap (or terminfo on some systems),
33: so it can run on a variety of terminals.
34: There is even limited support for hardcopy terminals.
35: (On a hardcopy terminal, lines which should be printed at the top
36: of the screen are prefixed with a caret.)
37: .PP
1.2 etheisen 38: This version of
39: .I less
40: also acts as
41: .I more
42: (1) if it is called as
43: .I more.
44: In this mode, the differences are in the prompt and that
45: .I more
46: exits by default when it gets to the end of the file.
47: Commands are based on both traditional
1.1 etheisen 48: .I more
49: and
50: .I vi.
51: Commands may be preceded by a decimal number,
52: called N in the descriptions below.
53: The number is used by some commands, as indicated.
54:
55: .SH COMMANDS
56: In the following descriptions, ^X means control-X.
57: ESC stands for the ESCAPE key; for example ESC-v means the
58: two character sequence "ESCAPE", then "v".
59: .IP "h or H"
60: Help: display a summary of these commands.
61: If you forget all the other commands, remember this one.
62: .PP
63: .IP "SPACE or ^V or f or ^F"
64: Scroll forward N lines, default one window (see option -z below).
65: If N is more than the screen size, only the final screenful is displayed.
66: Warning: some systems use ^V as a special literalization character.
67: .PP
68: .IP "z"
69: Like SPACE, but if N is specified, it becomes the new window size.
70: .PP
71: .IP "RETURN or ^N or e or ^E or j or ^J"
72: Scroll forward N lines, default 1.
73: The entire N lines are displayed, even if N is more than the screen size.
74: .PP
75: .IP "d or ^D"
76: Scroll forward N lines, default one half of the screen size.
77: If N is specified, it becomes the new default for
78: subsequent d and u commands.
79: .PP
80: .IP "b or ^B or ESC-v"
81: Scroll backward N lines, default one window (see option -z below).
82: If N is more than the screen size, only the final screenful is displayed.
83: .PP
84: .IP "w"
85: Like ESC-v, but if N is specified, it becomes the new window size.
86: .PP
87: .IP "y or ^Y or ^P or k or ^K"
88: Scroll backward N lines, default 1.
89: The entire N lines are displayed, even if N is more than the screen size.
90: Warning: some systems use ^Y as a special job control character.
91: .PP
92: .IP "u or ^U"
93: Scroll backward N lines, default one half of the screen size.
94: If N is specified, it becomes the new default for
95: subsequent d and u commands.
96: .PP
97: .IP "r or ^R or ^L"
98: Repaint the screen.
99: .PP
100: .IP R
101: Repaint the screen, discarding any buffered input.
102: Useful if the file is changing while it is being viewed.
103: .PP
104: .IP "F"
105: Scroll forward, and keep trying to read when the
106: end of file is reached.
107: Normally this command would be used when already at the end of the file.
108: It is a way to monitor the tail of a file which is growing
109: while it is being viewed.
110: (The behavior is similar to the "tail -f" command.)
111: .PP
112: .IP "g or < or ESC-<"
113: Go to line N in the file, default 1 (beginning of file).
114: (Warning: this may be slow if N is large.)
115: .PP
116: .IP "G or > or ESC->"
117: Go to line N in the file, default the end of the file.
118: (Warning: this may be slow if N is large,
119: or if N is not specified and
120: standard input, rather than a file, is being read.)
121: .PP
122: .IP "p or %"
123: Go to a position N percent into the file.
124: N should be between 0 and 100.
125: (This works if standard input is being read, but only if
126: .I less
127: has already read to the end of the file.
128: It is always fast, but not always useful.)
129: .PP
130: .IP "{"
131: If a left curly bracket appears in the top line displayed
132: on the screen,
133: the { command will go to the matching right curly bracket.
134: The matching right curly bracket is positioned on the bottom
135: line of the screen.
136: If there is more than one left curly bracket on the top line,
137: a number N may be used to specify the N-th bracket on the line.
138: .PP
139: .IP "}"
140: If a right curly bracket appears in the bottom line displayed
141: on the screen,
142: the } command will go to the matching left curly bracket.
143: The matching left curly bracket is positioned on the top
144: line of the screen.
145: If there is more than one right curly bracket on the top line,
146: a number N may be used to specify the N-th bracket on the line.
147: .PP
148: .IP "("
149: Like {, but applies to parentheses rather than curly brackets.
150: .PP
151: .IP ")"
152: Like }, but applies to parentheses rather than curly brackets.
153: .PP
154: .IP "["
155: Like {, but applies to square brackets rather than curly brackets.
156: .PP
157: .IP "]"
158: Like }, but applies to square brackets rather than curly brackets.
159: .PP
160: .IP "ESC-^F"
161: Followed by two characters,
162: acts like {, but uses the two characters as open and close brackets,
163: respectively.
164: For example, "ESC ^F < >" could be used to
165: go forward to the > which matches the < in the top displayed line.
166: .IP "ESC-^B"
167: Followed by two characters,
168: acts like }, but uses the two characters as open and close brackets,
169: respectively.
170: For example, "ESC ^B < >" could be used to
171: go backward to the < which matches the > in the bottom displayed line.
172: .IP m
173: Followed by any lowercase letter,
174: marks the current position with that letter.
175: .PP
176: .IP "'"
177: (Single quote.)
178: Followed by any lowercase letter, returns to the position which
179: was previously marked with that letter.
180: Followed by another single quote, returns to the position at
181: which the last "large" movement command was executed.
182: Followed by a ^ or $, jumps to the beginning or end of the
183: file respectively.
184: Marks are preserved when a new file is examined,
185: so the ' command can be used to switch between input files.
186: .PP
187: .IP "^X^X"
188: Same as single quote.
189: .PP
190: .IP /pattern
191: Search forward in the file for the N-th line containing the pattern.
192: N defaults to 1.
193: The pattern is a regular expression, as recognized by
194: .I ed.
195: The search starts at the second line displayed
196: (but see the -a and -j options, which change this).
197: .sp
198: Certain characters are special
199: if entered at the beginning of the pattern;
200: they modify the type of search rather than become part of the pattern:
201: .RS
202: .IP !
203: Search for lines which do NOT match the pattern.
204: .IP *
205: Search multiple files.
206: That is, if the search reaches the end of the current file
207: without finding a match,
208: the search continues in the next file in the command line list.
209: .IP @
210: Begin the search at the first line of the first file
211: in the command line list,
212: regardless of what is currently displayed on the screen
213: or the settings of the -a or -j options.
214: .RE
215: .PP
216: .IP ?pattern
217: Search backward in the file for the N-th line containing the pattern.
218: The search starts at the line immediately before the top line displayed.
219: .sp
220: Certain characters are special as in the / command:
221: .RS
222: .IP !
223: Search for lines which do NOT match the pattern.
224: .IP *
225: Search multiple files.
226: That is, if the search reaches the beginning of the current file
227: without finding a match,
228: the search continues in the previous file in the command line list.
229: .IP @
230: Begin the search at the last line of the last file
231: in the command line list,
232: regardless of what is currently displayed on the screen
233: or the settings of the -a or -j options.
234: .RE
235: .PP
236: .IP "ESC-/pattern"
237: Same as "/*".
238: .PP
239: .IP "ESC-?pattern"
240: Same as "?*".
241: .PP
242: .IP n
243: Repeat previous search, for N-th line containing the last pattern.
244: If the previous search was modified by !, the search is made for the
245: N-th line NOT containing the pattern.
246: If the previous search was modified by *, the search continues
247: in the next (or previous) file if not satisfied in the current file.
248: There is no effect if the previous search was modified by @.
249: .PP
250: .IP N
251: Repeat previous search, but in the reverse direction.
252: .PP
253: .IP "ESC-n"
254: Repeat previous search, but crossing file boundaries.
255: The effect is as if the previous search were modified by *.
256: .PP
257: .IP "ESC-N"
258: Repeat previous search, but in the reverse direction
259: and crossing file boundaries.
260: .PP
261: .IP "ESC-u"
262: Undo search highlighting.
263: Turn off highlighting of strings matching the current search pattern.
264: If highlighting is already off because of a previous ESC-u command,
265: turn highlighting back on.
266: Any search command will also turn highlighting back on.
267: (Highlighting can also be disabled by toggling the -G flag;
268: in that case search commands do not turn highlighting back on.)
269: .PP
270: .IP ":e [filename]"
271: Examine a new file.
272: If the filename is missing, the "current" file (see the :n and :p commands
273: below) from the list of files in the command line is re-examined.
274: A percent sign (%) in the filename is replaced by the name of the
275: current file.
276: A pound sign (#) is replaced by the name of the previously examined file.
277: The filename is inserted into the command line list of files
278: so that it can be seen by subsequent :n and :p commands.
279: If the filename consists of several files, they are all inserted into
280: the list of files and the first one is examined.
281: .PP
282: .IP "^X^V or E"
283: Same as :e.
284: Warning: some systems use ^V as a special literalization character.
285: .PP
286: .IP ":n"
287: Examine the next file (from the list of files given in the command line).
288: If a number N is specified, the N-th next file is examined.
289: .PP
290: .IP ":p"
291: Examine the previous file in the command line list.
292: If a number N is specified, the N-th previous file is examined.
293: .PP
1.2 etheisen 294: .IP ":t"
295: Go to supplied tag.
296: .PP
1.1 etheisen 297: .IP ":x"
298: Examine the first file in the command line list.
299: If a number N is specified, the N-th file in the list is examined.
300: .PP
301: .IP "= or ^G or :f"
302: Prints some information about the file being viewed,
303: including its name
304: and the line number and byte offset of the bottom line being displayed.
305: If possible, it also prints the length of the file,
306: the number of lines in the file
307: and the percent of the file above the last displayed line.
308: .PP
309: .IP \-
310: Followed by one of the command line option letters (see below),
311: this will change the setting of that option
312: and print a message describing the new setting.
313: If the option letter has a numeric value (such as -b or -h),
314: or a string value (such as -P or -t),
315: a new value may be entered after the option letter.
316: If no new value is entered, a message describing
317: the current setting is printed and nothing is changed.
318: .PP
319: .IP \-+
320: Followed by one of the command line option letters (see below),
321: this will reset the option to its default setting
322: and print a message describing the new setting.
323: (The "\-+\fIX\fP" command does the same thing
324: as "\-+\fIX\fP" on the command line.)
325: This does not work for string-valued options.
326: .PP
327: .IP \-\-
328: Followed by one of the command line option letters (see below),
329: this will reset the option to the "opposite" of its default setting
330: and print a message describing the new setting.
331: (The "\-\-\fIX\fP" command does the same thing
332: as "\-\fIX\fP" on the command line.)
333: This does not work for numeric or string-valued options.
334: .PP
335: .IP _
336: (Underscore.)
337: Followed by one of the command line option letters (see below),
338: this will print a message describing the current setting of that option.
339: The setting of the option is not changed.
340: .PP
341: .IP +cmd
342: Causes the specified cmd to be executed each time a new file is examined.
343: For example, +G causes
344: .I less
345: to initially display each file starting at the end
346: rather than the beginning.
347: .PP
348: .IP V
349: Prints the version number of
350: .I less
351: being run.
352: .PP
353: .IP "q or :q or :Q or ZZ"
354: Exits
355: .I less.
356: .PP
357: The following
358: three
359: commands may or may not be valid, depending on your particular installation.
360: .PP
361: .IP v
362: Invokes an editor to edit the current file being viewed.
363: The editor is taken from the environment variable VISUAL if defined,
364: or EDITOR if VISUAL is not defined,
365: or defaults to "vi" if neither VISUAL nor EDITOR is defined.
366: See also the discussion of LESSEDIT under the section on PROMPTS below.
367: .PP
368: .IP "! shell-command"
369: Invokes a shell to run the shell-command given.
370: A percent sign (%) in the command is replaced by the name of the
371: current file.
372: A pound sign (#) is replaced by the name of the previously examined file.
373: "!!" repeats the last shell command.
374: "!" with no shell command simply invokes a shell.
375: In all cases, the shell is taken from the environment variable SHELL,
376: or defaults to "sh".
377: .PP
378: .IP "| <m> shell-command"
379: <m> represents any mark letter.
380: Pipes a section of the input file to the given shell command.
381: The section of the file to be piped is between the first line on
382: the current screen and the position marked by the letter.
383: <m> may also be ^ or $ to indicate beginning or end of file respectively.
384: If <m> is . or newline, the current screen is piped.
385: .PP
386: .SH OPTIONS
387: Command line options are described below.
388: Most options may be changed while
389: .I less
390: is running, via the "\-" command.
391: .PP
1.2 etheisen 392: Options are also taken from the environment variable "LESS" if the
393: command is
394: .I less
395: , or from the environment variable "MORE" if the command is
396: .I more.
1.1 etheisen 397: For example,
398: to avoid typing "less -options ..." each time
399: .I less
400: is invoked, you might tell
401: .I csh:
402: .sp
403: setenv LESS "-options"
404: .sp
405: or if you use
406: .I sh:
407: .sp
408: LESS="-options"; export LESS
409: .sp
410: The environment variable is parsed before the command line,
411: so command line options override the LESS environment variable.
412: If an option appears in the LESS variable, it can be reset
413: to its default on the command line by beginning the command
414: line option with "-+".
415: .sp
416: A dollar sign ($) may be used to signal the end of an option string.
417: This is important only for options like -P which take a
418: following string.
419: .IP -?
420: This option displays a summary of the commands accepted by
421: .I less
422: (the same as the h command).
423: If this option is given, all other options are ignored, and
424: .I less
425: exits after the help screen is viewed.
426: (Depending on how your shell interprets the question mark,
427: it may be necessary to quote the question mark, thus: "-\\?".)
428: .IP -a
429: Causes searches to start after the last line
430: displayed on the screen,
431: thus skipping all lines displayed on the screen.
432: By default, searches start at the second line on the screen
433: (or after the last found line; see the -j option).
434: .IP -b\fIn\fP
435: Specifies the number of buffers
436: .I less
437: will use for each file.
438: Buffers are 1K, and by default 10 buffers are used for each file
439: (except if the file is a pipe; see the -B option).
440: The number \fIn\fP specifies a different number of buffers to use.
441: .IP -B
442: By default, when data is read from a pipe,
443: buffers are allocated automatically as needed.
444: If a large amount of data is read from the pipe, this can cause
445: a large amount of memory to be allocated.
446: The -B option disables this automatic allocation of buffers for pipes,
447: so that only the number of buffers specified by the -b option are used.
448: Warning: use of -B can result in erroneous display, since only the
449: most recently viewed part of the file is kept in memory;
450: any earlier data is lost.
451: .IP -c
452: Causes full screen repaints to be painted from the top line down.
453: By default,
454: full screen repaints are done by scrolling from the bottom of the screen.
455: .IP -C
456: The -C option is like -c, but the screen is cleared before it is repainted.
457: .IP -d
1.2 etheisen 458: The -d option causes the default prompt to include the basic directions
459: ``[Press space to continue, 'q' to quit.]''. The -d
460: option also causes the message ``[Press 'h' for instructions.]'' to be
461: displayed when an invalid command is entered (normally, the bell is
462: rung). This option is useful in environments where users may not be
463: experienced with pagers.
1.1 etheisen 464: .IP -D\fBx\fP\fIcolor\fP
465: [MS-DOS only]
466: Sets the color of the text displayed.
467: \fBx\fP is a single character which selects the type of text whose color is
468: being set: n=normal, s=standout, d=bold, u=underlined, k=blink.
469: \fIcolor\fP is a pair of numbers separated by a period.
470: The first number selects the foreground color and the second selects
471: the background color of the text.
472: A single number \fIN\fP is the same as \fIN.0\fP.
473: .IP -e
474: Causes
475: .I less
476: to automatically exit
477: the second time it reaches end-of-file.
478: By default, the only way to exit
479: .I less
1.2 etheisen 480: is via the "q" command, except in
481: .I more
482: mode, where
483: .I less
484: will exit at the end of a file.
1.1 etheisen 485: .IP -E
486: Causes
487: .I less
488: to automatically exit the first time it reaches end-of-file.
489: .IP -f
490: Forces non-regular files to be opened.
491: (A non-regular file is a directory or a device special file.)
492: Also suppresses the warning message when a binary file is opened.
493: By default,
494: .I less
495: will refuse to open non-regular files.
496: .IP -g
497: Normally,
498: .I less
499: will highlight ALL strings which match the last search command.
500: The -g flag changes this behavior to highlight only the particular string
501: which was found by the last search command.
502: This can cause
503: .I less
504: to run somewhat faster than the default.
505: .IP -G
506: The -G flag suppresses all highlighting of strings found by search commands.
507: .IP -h\fIn\fP
508: Specifies a maximum number of lines to scroll backward.
509: If it is necessary to scroll backward more than \fIn\fP lines,
510: the screen is repainted in a forward direction instead.
511: (If the terminal does not have the ability to scroll
512: backward, -h0 is implied.)
513: .IP -i
514: Causes searches to ignore case; that is,
515: uppercase and lowercase are considered identical.
516: This option is ignored if any uppercase letters
517: appear in the search pattern;
518: in other words,
519: if a pattern contains uppercase letters, then that search does not ignore case.
520: .IP -I
521: Like -i, but searches ignore case even if
522: the pattern contains uppercase letters.
523: .IP -j\fIn\fP
524: Specifies a line on the screen where the "target" line
525: is to be positioned.
526: A target line is the object of a text search,
527: tag search, jump to a line number,
528: jump to a file percentage, or jump to a marked position.
529: The screen line is specified by a number: the top line on the screen
530: is 1, the next is 2, and so on.
531: The number may be negative to specify a line relative to the bottom
532: of the screen: the bottom line on the screen is -1, the second
533: to the bottom is -2, and so on.
534: If the -j option is used, searches begin at the line immediately
535: after the target line.
536: For example, if "-j4" is used, the target line is the
537: fourth line on the screen, so searches begin at the fifth line
538: on the screen.
539: .IP -k\fIfilename\fP
540: Causes
541: .I less
542: to open and interpret the named file as a
543: .I lesskey
544: (1) file.
545: Multiple -k options may be specified.
546: If a file called .less exists in the user's home directory, this
547: file is also used as a
548: .I lesskey
549: file.
550: .IP -m
551: Causes
552: .I less
553: to prompt verbosely (like \fImore\fP),
554: with the percent into the file.
555: By default,
556: .I less
557: prompts with a colon.
558: .IP -M
559: Causes
560: .I less
561: to prompt even more verbosely than
562: .I more.
563: .IP -n
564: Suppresses line numbers.
565: The default (to use line numbers) may cause
566: .I less
567: to run more slowly in some cases, especially with a very large input file.
568: Suppressing line numbers with the -n flag will avoid this problem.
569: Using line numbers means: the line number will be displayed in the verbose
570: prompt and in the = command,
571: and the v command will pass the current line number to the editor
572: (see also the discussion of LESSEDIT in PROMPTS below).
573: .IP -N
574: Causes a line number to be displayed at the beginning of
575: each line in the display.
576: .IP -o\fIfilename\fP
577: Causes
578: .I less
579: to copy its input to the named file as it is being viewed.
580: This applies only when the input file is a pipe,
581: not an ordinary file.
582: If the file already exists,
583: .I less
584: will ask for confirmation before overwriting it.
585: .IP -O\fIfilename\fP
586: The -O option is like -o, but it will overwrite an existing
587: file without asking for confirmation.
588: .sp
589: If no log file has been specified,
590: the -o and -O options can be used from within
591: .I less
592: to specify a log file.
593: Without a file name, they will simply report the name of the log file.
594: The "s" command is equivalent to specifying -o from within
595: .I less.
596: .IP -p\fIpattern\fP
597: The -p option on the command line is equivalent to
598: specifying +/\fIpattern\fP;
599: that is, it tells
600: .I less
601: to start at the first occurrence of \fIpattern\fP in the file.
602: .IP -P\fIprompt\fP
603: Provides a way to tailor the three prompt
604: styles to your own preference.
605: This option would normally be put in the LESS environment
606: variable, rather than being typed in with each
607: .I less
608: command.
609: Such an option must either be the last option in the LESS variable,
610: or be terminated by a dollar sign.
611: -P followed by a string changes the default (short) prompt to that string.
612: -Pm changes the medium (-m) prompt to the string, and
613: -PM changes the long (-M) prompt.
614: Also, -P= changes the message printed by the = command to the given string.
615: All prompt strings consist of a sequence of
616: letters and special escape sequences.
617: See the section on PROMPTS for more details.
618: .IP -q
619: Causes moderately "quiet" operation:
620: the terminal bell is not rung
621: if an attempt is made to scroll past the end of the file
622: or before the beginning of the file.
623: If the terminal has a "visual bell", it is used instead.
624: The bell will be rung on certain other errors,
625: such as typing an invalid character.
626: The default is to ring the terminal bell in all such cases.
627: .IP -Q
628: Causes totally "quiet" operation:
629: the terminal bell is never rung.
630: .IP -r
631: Causes "raw" control characters to be displayed.
632: The default is to display control characters using the caret notation;
633: for example, a control-A (octal 001) is displayed as "^A".
634: Warning: when the -r flag is used,
635: .I less
636: cannot keep track of the actual appearance of the screen
637: (since this depends on how the screen responds to
638: each type of control character).
639: Thus, various display problems may result,
640: such as long lines being split in the wrong place.
641: .IP -s
642: Causes consecutive blank lines to be squeezed into a single blank line.
643: This is useful when viewing
644: .I nroff
645: output.
646: .IP -S
647: Causes lines longer than the screen width to be
648: chopped rather than folded.
649: That is, the remainder of a long line is simply discarded.
650: The default is to fold long lines; that is, display the remainder
651: on the next line.
652: .IP -t\fItag\fP
653: The -t option, followed immediately by a TAG,
654: will edit the file containing that tag.
655: For this to work, there must be a file called "tags" in the
656: current directory, which was previously built by the
657: .I ctags
658: (1) command.
659: This option may also be specified from within
660: .I less
661: (using the \- command) as a way of examining a new file.
662: The command ":t" is equivalent to specifying -t from within
663: .I less.
664: .IP -T\fItagsfile\fP
665: Specifies a tags file to be used instead of "tags".
666: .IP -u
667: Causes backspaces and carriage returns to be treated as printable characters;
668: that is, they are sent to the terminal when they appear in the input.
669: .IP -U
670: Causes backspaces and carriage returns to be treated as control characters;
671: that is, they are handled as specified by the -r option.
672: .sp
673: By default, if neither -u nor -U is given,
674: backspaces which appear adjacent to an underscore character
675: are treated specially:
676: the underlined text is displayed
677: using the terminal's hardware underlining capability.
678: Also, backspaces which appear between two identical characters
679: are treated specially:
680: the overstruck text is printed
681: using the terminal's hardware boldface capability.
682: Other backspaces are deleted, along with the preceding character.
683: Carriage returns immediately followed by a newline are deleted.
684: Other carriage returns are handled as specified by the -r option.
685: Text which is overstruck or underlined can be searched for
686: if neither -u nor -U is in effect.
687: .IP -V
688: Displays the version number of
689: .I less.
690: .IP -w
691: Causes blank lines to be used to represent lines
692: past the end of the file.
693: By default,
694: a tilde character (~) is used.
695: .IP -x\fIn\fP
696: Sets tab stops every \fIn\fP positions.
697: The default for \fIn\fP is 8.
698: .IP -X
699: Disables sending the termcap initialization and deinitialization strings
700: to the terminal.
701: This is sometimes desirable if the deinitialization string does
702: something unnecessary, like clearing the screen.
703: .IP -y\fIn\fP
704: Specifies a maximum number of lines to scroll forward.
705: If it is necessary to scroll forward more than \fIn\fP lines,
706: the screen is repainted instead.
707: The -c or -C option may be used to repaint from the top of
708: the screen if desired.
709: By default, any forward movement causes scrolling.
710: .IP -[z]\fIn\fP
711: Changes the default scrolling window size to \fIn\fP lines.
712: The default is one screenful.
713: The z and w commands can also be used to change the window size.
714: The "z" may be omitted for compatibility with
715: .I more.
716: If the number
717: .I n
718: is negative, it indicates
719: .I n
720: lines less than the current screen size.
721: For example, if the screen is 24 lines, \fI-z-4\fP sets the
722: scrolling window to 20 lines. If the screen is resized to 40 lines,
723: the scrolling window automatically changes to 36 lines.
724: .IP +
725: If a command line option begins with \fB+\fP,
726: the remainder of that option is taken to be an initial command to
727: .I less.
728: For example, +G tells
729: .I less
730: to start at the end of the file rather than the beginning,
731: and +/xyz tells it to start at the first occurrence of "xyz" in the file.
732: As a special case, +<number> acts like +<number>g;
733: that is, it starts the display at the specified line number
734: (however, see the caveat under the "g" command above).
735: If the option starts with ++, the initial command applies to
736: every file being viewed, not just the first one.
737: The + command described previously
738: may also be used to set (or change) an initial command for every file.
739:
740: .SH "LINE EDITING"
741: When entering command line at the bottom of the screen
742: (for example, a filename for the :e command,
743: or the pattern for a search command),
744: certain keys can be used to manipulate the command line.
745: Most commands have an alternate form in [ brackets ] which can be used if
746: a key does not exist on a particular keyboard.
747: (The bracketed forms do not work in the MS-DOS version.)
748: Any of these special keys may be entered literally by preceding
749: it with the "literal" character, either ^V or ^A.
750: A backslash itself may also be entered literally by entering two backslashes.
751: .IP "LEFTARROW [ ESC-h ]"
752: Move the cursor one space to the left.
753: .IP "RIGHTARROW [ ESC-l ]"
754: Move the cursor one space to the right.
755: .IP "^LEFTARROW [ ESC-b or ESC-LEFTARROW ]"
756: (That is, CONTROL and LEFTARROW simultaneously.)
757: Move the cursor one word to the left.
758: .IP "^RIGHTARROW [ ESC-w or ESC-RIGHTARROW ]"
759: (That is, CONTROL and RIGHTARROW simultaneously.)
760: Move the cursor one word to the right.
761: .IP "HOME [ ESC-0 ]"
762: Move the cursor to the beginning of the line.
763: .IP "END [ ESC-$ ]"
764: Move the cursor to the end of the line.
765: .IP "BACKSPACE"
766: Delete the character to the left of the cursor,
767: or cancel the command if the command line is empty.
768: .IP "DELETE or [ ESC-x ]"
769: Delete the character under the cursor.
770: .IP "^BACKSPACE [ ESC-BACKSPACE ]"
771: (That is, CONTROL and BACKSPACE simultaneously.)
772: Delete the word to the left of the cursor.
773: .IP "^DELETE [ ESC-X or ESC-DELETE ]"
774: (That is, CONTROL and DELETE simultaneously.)
775: Delete the word under the cursor.
776: .IP "UPARROW [ ESC-k ]"
777: Retrieve the previous command line.
778: .IP "DOWNARROW [ ESC-j ]"
779: Retrieve the next command line.
780: .IP "TAB"
781: Complete the partial filename to the left of the cursor.
782: If it matches more than one filename, the first match
783: is entered into the command line.
784: Repeated TABs will cycle thru the other matching filenames.
785: .IP "BACKTAB [ ESC-TAB ]"
786: Like, TAB, but cycles in the reverse direction thru the matching filenames.
787: .IP "^L"
788: Complete the partial filename to the left of the cursor.
789: If it matches more than one filename, all matches are entered into
790: the command line (if they fit).
791: .IP "^U (Unix) or ESC (MS-DOS)"
792: Delete the entire command line,
793: or cancel the command if the command line is empty.
794: If you have changed your line-kill character in Unix to something
795: other than ^U, that character is used instead of ^U.
796:
797: .SH "KEY BINDINGS"
798: You may define your own
799: .I less
800: commands by using the program
801: .I lesskey
802: (1)
803: to create a file called ".less" in your home directory.
804: This file specifies a set of command keys and an action
805: associated with each key.
806: You may also use
807: .I lesskey
808: to change the line-editing keys (see LINE EDITING).
809: See the
810: .I lesskey
811: manual page for more details.
812:
813: .SH "INPUT PREPROCESSOR"
814: You may define an "input preprocessor" for
815: .I less.
816: Before
817: .I less
818: opens a file, it first gives your input preprocessor a chance to modify the
819: way the contents of the file are displayed.
820: An input preprocessor is simply an executable program (or shell script),
821: which writes the contents of the file to a different file,
822: called the replacement file.
823: The contents of the replacement file are then displayed
824: in place of the contents of the original file.
825: However, it will appear to the user as if the original file is opened;
826: that is,
827: .I less
828: will display the original filename as the name of the current file.
829: .PP
830: An input preprocessor receives one command line argument, the original filename,
831: as entered by the user.
832: It should create the replacement file, and when finished,
833: print the name of the replacement file to its standard output.
834: If the input preprocessor does not output a replacement filename,
835: .I less
836: uses the original file, as normal.
837: The input preprocessor is not called when viewing standard input.
838: To set up an input preprocessor, set the LESSOPEN environment variable
839: to a command line which will invoke your input preprocessor.
840: This command line should include one occurrence of the string "%s",
841: which will be replaced by the filename
842: when the input preprocessor command is invoked.
843: .PP
844: When
845: .I less
846: closes a file opened in such a way, it will call another program,
847: called the input postprocessor,
848: which may perform any desired clean-up action (such as deleting the
849: replacement file created by LESSOPEN).
850: This program receives two command line arguments, the original filename
851: as entered by the user, and the name of the replacement file.
852: To set up an input postprocessor, set the LESSCLOSE environment variable
853: to a command line which will invoke your input postprocessor.
854: It may include two occurrences of the string "%s";
855: the first is replaced with the original name of the file and
856: the second with the name of the replacement file,
857: which was output by LESSOPEN.
858: .PP
859: For example, on many Unix systems, these two scripts will allow you
860: to keep files in compressed format, but still let
861: .I less
862: view them directly:
863: .PP
864: lessopen.sh:
865: .br
866: #! /bin/sh
867: .br
868: case "$1" in
869: .br
1.3 ! millert 870: *.Z|*.gz) TFILE=`mktemp /tmp/less.XXXXXX` || exit 1
1.1 etheisen 871: .br
1.3 ! millert 872: gunzip -c $1 >${TFILE} 2>/dev/null
1.1 etheisen 873: .br
1.3 ! millert 874: if [ -s ${TFILE} ]; then
! 875: .br
! 876: echo ${TFILE}
1.1 etheisen 877: .br
878: else
879: .br
1.3 ! millert 880: rm -f ${TFILE}
1.1 etheisen 881: .br
882: fi
883: .br
884: ;;
885: .br
886: esac
887: .PP
888: lessclose.sh:
889: .br
890: #! /bin/sh
891: .br
892: rm $2
893: .PP
894: To use these scripts, put them both where they can be executed and
895: set LESSOPEN="lessopen.sh\ %s", and
896: LESSCLOSE="lessclose.sh\ %s\ %s".
897: More complex LESSOPEN and LESSCLOSE scripts may be written
898: to accept other types of compressed files, and so on.
899: .PP
900: It is also possible to set up an input preprocessor to
901: pipe the file data directly to
902: .I less,
903: rather than putting the data into a replacement file.
904: This avoids the need to decompress the entire file before
905: starting to view it.
906: An input preprocessor that works this way is called an input pipe.
907: An input pipe, instead of writing the name of a replacement file on
908: its standard output,
909: writes the entire contents of the replacement file on its standard output.
910: If the input pipe does not write any characters on its standard output,
911: then there is no replacement file and
912: .I less
913: uses the original file, as normal.
914: To use an input pipe,
915: make the first character in the LESSOPEN environment variable a
916: vertical bar (|) to signify that the input preprocessor is an input pipe.
917: .PP
918: For example, on many Unix systems, this script will work like the
919: previous example scripts:
920: .PP
921: lesspipe.sh:
922: .br
923: !# /bin/sh
924: .br
925: case "$1" in
926: .br
927: *.Z) uncompress -c $1 2>/dev/null
928: .br
929: ;;
930: .br
931: esac
932: .br
933: .PP
934: To use this script, put it where it can be executed and set
935: LESSOPEN="|lesspipe.sh %s".
936: When an input pipe is used, a LESSCLOSE postprocessor can be used,
937: but it is usually not necessary since there is no replacement file
938: to clean up.
939: In this case, the replacement file name passed to the LESSCLOSE
940: postprocessor is "-".
941:
942: .SH "NATIONAL CHARACTER SETS"
943: There are three types of characters in the input file:
944: .IP "normal characters"
945: can be displayed directly to the screen.
946: .IP "control characters"
947: should not be displayed directly, but are expected to be found
948: in ordinary text files (such as backspace and tab).
949: .IP "binary characters"
950: should not be displayed directly and are not expected to be found
951: in text files.
952: .PP
953: A "character set" is simply a description of which characters are to
954: be considered normal, control, and binary.
955: The LESSCHARSET environment variable may be used to select a character set.
956: Possible values for LESSCHARSET are:
957: .IP ascii
958: The default character set.
959: BS, TAB, NL, CR, and formfeed are control characters,
960: all chars with values between 127 and 255 are binary,
961: and all others are normal.
962: .IP latin1
963: Selects the ISO 8859/1 character set.
964: latin-1 is the same as ASCII, except characters between 161 and 255 are
965: treated as normal characters.
966: .IP dos
967: Selects a character set appropriate for MS-DOS.
968: .IP koi8-r
969: Selects a Russian character set.
970: .IP next
971: Selects a character set appropriate for NeXT computers.
972: .PP
973: In special cases, it may be desired to tailor
974: .I less
975: to use a character set other than the ones definable by LESSCHARSET.
976: In this case, the environment variable LESSCHARDEF can be used
977: to define a character set.
978: It should be set to a string where each character in the string represents
979: one character in the character set.
980: The character "." is used for a normal character, "c" for control,
981: and "b" for binary.
982: A decimal number may be used for repetition.
983: For example, "bccc4b." would mean character 0 is binary,
984: 1, 2 and 3 are control, 4, 5, 6 and 7 are binary, and 8 is normal.
985: All characters after the last are taken to be the same as the last,
986: so characters 9 through 255 would be normal.
987: (This is an example, and does not necessarily
988: represent any real character set.)
989: .PP
990: This table shows the value of LESSCHARDEF which is equivalent
991: to each of the possible values for LESSCHARSET:
992: .sp
993: ascii\ 8bcccbcc18b95.b
994: .br
995: latin1 8bcccbcc18b95.33b.
996: .br
997: dos\ \ \ 8bcccbcc12bc5b95.b.
998: .br
999: koi8-r 8bcccbcc18b95.b128.
1000: .br
1001: next\ \ 8bcccbcc18b95.bb125.bb
1002: .PP
1003: If neither LESSCHARSET nor LESSCHARDEF is set,
1004: but your system supports the
1005: .I setlocale
1006: interface,
1007: .I less
1008: will use setlocale to determine the character set.
1009: setlocale is controlled by setting the LANG or LC_CTYPE environment variables.
1010: .PP
1011: Control and binary characters are displayed in standout (reverse video).
1012: Each such character is displayed in caret notation if possible
1013: (e.g. ^A for control-A). Caret notation is used only if
1014: inverting the 0100 bit results in a normal printable character.
1015: Otherwise, the character is displayed as a hex number in angle brackets.
1016: This format can be changed by
1017: setting the LESSBINFMT environment variable.
1018: LESSBINFMT may begin with a "*" and one character to select
1019: the display attribute:
1020: "*k" is blinking, "*d" is bold, "*u" is underlined, "*s" is standout.
1021: If LESSBINFMT does not begin with a "*", normal attribute is assumed.
1022: The remainder of LESSBINFMT is a string which may include one
1023: printf-style escape sequence (a % followed by x, X, o, d, etc.).
1024: For example, if LESSBINFMT is "*u[%x]", binary characters
1025: are displayed in underlined hexadecimal surrounded by brackets.
1026: The default if no LESSBINFMT is specified is "*d<%X>".
1027:
1028: .SH "PROMPTS"
1029: The -P option allows you to tailor the prompt to your preference.
1030: The string given to the -P option replaces the specified prompt string.
1031: Certain characters in the string are interpreted specially.
1032: The prompt mechanism is rather complicated to provide flexibility,
1033: but the ordinary user need not understand the details of constructing
1034: personalized prompt strings.
1035: .sp
1036: A percent sign followed by a single character is expanded
1037: according to what the following character is:
1038: .IP "%b\fIX\fP"
1039: Replaced by the byte offset into the current input file.
1040: The b is followed by a single character (shown as \fIX\fP above)
1041: which specifies the line whose byte offset is to be used.
1042: If the character is a "t", the byte offset of the top line in the
1043: display is used,
1044: an "m" means use the middle line,
1045: a "b" means use the bottom line,
1046: a "B" means use the line just after the bottom line,
1047: and a "j" means use the "target" line, as specified by the -j option.
1048: .IP "%B"
1049: Replaced by the size of the current input file.
1050: .IP "%E"
1051: Replaced by the name of the editor (from the VISUAL environment variable,
1052: or the EDITOR environment variable if VISUAL is not defined).
1053: See the discussion of the LESSEDIT feature below.
1054: .IP "%f"
1055: Replaced by the name of the current input file.
1056: .IP "%i"
1057: Replaced by the index of the current file in the list of
1058: input files.
1059: .IP "%l\fIX\fP"
1060: Replaced by the line number of a line in the input file.
1061: The line to be used is determined by the \fIX\fP, as with the %b option.
1062: .IP "%L"
1063: Replaced by the line number of the last line in the input file.
1064: .IP "%m"
1065: Replaced by the total number of input files.
1066: .IP "%p\fIX\fP"
1067: Replaced by the percent into the current input file.
1068: The line used is determined by the \fIX\fP as with the %b option.
1069: .IP "%s"
1070: Same as %B.
1071: .IP "%t"
1072: Causes any trailing spaces to be removed.
1073: Usually used at the end of the string, but may appear anywhere.
1074: .IP "%x"
1075: Replaced by the name of the next input file in the list.
1076: .PP
1077: If any item is unknown (for example, the file size if input
1078: is a pipe), a question mark is printed instead.
1079: .PP
1080: The format of the prompt string can be changed
1081: depending on certain conditions.
1082: A question mark followed by a single character acts like an "IF":
1083: depending on the following character, a condition is evaluated.
1084: If the condition is true, any characters following the question mark
1085: and condition character, up to a period, are included in the prompt.
1086: If the condition is false, such characters are not included.
1087: A colon appearing between the question mark and the
1088: period can be used to establish an "ELSE": any characters between
1089: the colon and the period are included in the string if and only if
1090: the IF condition is false.
1091: Condition characters (which follow a question mark) may be:
1092: .IP "?a"
1093: True if any characters have been included in the prompt so far.
1094: .IP "?b\fIX\fP"
1095: True if the byte offset of the specified line is known.
1096: .IP "?B"
1097: True if the size of current input file is known.
1098: .IP "?e"
1099: True if at end-of-file.
1100: .IP "?f"
1101: True if there is an input filename
1102: (that is, if input is not a pipe).
1103: .IP "?l\fIX\fP"
1104: True if the line number of the specified line is known.
1105: .IP "?L"
1106: True if the line number of the last line in the file is known.
1107: .IP "?m"
1108: True if there is more than one input file.
1109: .IP "?n"
1110: True if this is the first prompt in a new input file.
1111: .IP "?p\fIX\fP"
1112: True if the percent into the current input file
1113: of the specified line is known.
1114: .IP "?s"
1115: Same as "?B".
1116: .IP "?x"
1117: True if there is a next input file
1118: (that is, if the current input file is not the last one).
1119: .PP
1120: Any characters other than the special ones
1121: (question mark, colon, period, percent, and backslash)
1122: become literally part of the prompt.
1123: Any of the special characters may be included in the prompt literally
1124: by preceding it with a backslash.
1125: .PP
1126: Some examples:
1127: .sp
1128: ?f%f:Standard input.
1129: .sp
1130: This prompt prints the filename, if known;
1131: otherwise the string "Standard input".
1132: .sp
1133: ?f%f .?ltLine %lt:?pt%pt\\%:?btByte %bt:-...
1134: .sp
1135: This prompt would print the filename, if known.
1136: The filename is followed by the line number, if known,
1137: otherwise the percent if known, otherwise the byte offset if known.
1138: Otherwise, a dash is printed.
1139: Notice how each question mark has a matching period,
1140: and how the % after the %pt
1141: is included literally by escaping it with a backslash.
1142: .sp
1143: ?n?f%f\ .?m(file\ %i\ of\ %m)\ ..?e(END)\ ?x-\ Next\\:\ %x..%t
1144: .sp
1145: This prints the filename if this is the first prompt in a file,
1146: followed by the "file N of N" message if there is more
1147: than one input file.
1148: Then, if we are at end-of-file, the string "(END)" is printed
1149: followed by the name of the next file, if there is one.
1150: Finally, any trailing spaces are truncated.
1151: This is the default prompt.
1152: For reference, here are the defaults for
1153: the other two prompts (-m and -M respectively).
1154: Each is broken into two lines here for readability only.
1155: .nf
1156: .sp
1157: ?n?f%f\ .?m(file\ %i\ of\ %m)\ ..?e(END)\ ?x-\ Next\\:\ %x.:
1158: ?pB%pB\\%:byte\ %bB?s/%s...%t
1159: .sp
1160: ?f%f\ .?n?m(file\ %i\ of\ %m)\ ..?ltline\ %lt?L/%L.\ :byte\ %bB?s/%s.\ .
1161: ?e(END)\ ?x-\ Next\\:\ %x.:?pB%pB\\%..%t
1162: .sp
1163: .fi
1164: And here is the default message produced by the = command:
1165: .nf
1166: .sp
1167: ?f%f\ .?m(file\ %i\ of\ %m)\ .?ltline\ %lt?L/%L.\ .
1168: byte\ %bB?s/%s.\ ?e(END)\ :?pB%pB\\%..%t
1169: .fi
1170: .PP
1171: The prompt expansion features are also used for another purpose:
1172: if an environment variable LESSEDIT is defined, it is used
1173: as the command to be executed when the v command is invoked.
1174: The LESSEDIT string is expanded in the same way as the prompt strings.
1175: The default value for LESSEDIT is:
1176: .nf
1177: .sp
1178: %E\ ?lm+%lm.\ %f
1179: .sp
1180: .fi
1181: Note that this expands to the editor name, followed by a + and the
1182: line number, followed by the file name.
1183: If your editor does not accept the "+linenumber" syntax, or has other
1184: differences in invocation syntax, the LESSEDIT variable can be
1185: changed to modify this default.
1186:
1187: .SH "ENVIRONMENT VARIABLES"
1188: .IP COLUMNS
1189: Sets the number of columns on the screen.
1190: Takes precedence over the number of columns specified by the TERM variable.
1191: (But if you have a windowing system which supports TIOCGWINSZ or WIOCGETD,
1192: the window system's idea of the screen size takes precedence over the
1193: LINES and COLUMNS environment variables.)
1194: .IP EDITOR
1195: The name of the editor (used for the v command).
1196: .IP HOME
1197: Name of the user's home directory (used to find a .less file).
1198: .IP LANG
1199: Language for determining the character set.
1200: .IP LC_CTYPE
1201: Language for determining the character set.
1202: .IP LESS
1203: Flags which are passed to
1204: .I less
1.2 etheisen 1205: automatically.
1206: .IP MORE
1207: Flags which are passed to
1208: .I more
1.1 etheisen 1209: automatically.
1210: .IP LESSBINFMT
1211: Format for displaying non-printable, non-control characters.
1212: .IP LESSCHARDEF
1213: Defines a character set.
1214: .IP LESSCHARSET
1215: Selects a predefined character set.
1216: .IP LESSCLOSE
1217: Command line to invoke the (optional) input-postprocessor.
1218: .IP LESSEDIT
1219: Editor prototype string (used for the v command).
1220: See discussion under PROMPTS.
1221: .IP LESSHELP
1222: Name of the help file.
1223: .IP LESSOPEN
1224: Command line to invoke the (optional) input-preprocessor.
1225: .IP LINES
1226: Sets the number of lines on the screen.
1227: Takes precedence over the number of lines specified by the TERM variable.
1228: .IP SHELL
1229: The shell used to execute the ! command, as well as to expand filenames.
1230: .IP TERM
1231: The type of terminal on which
1232: .I less
1233: is being run.
1234: .IP VISUAL
1235: The name of the editor (used for the v command).
1236:
1237: .SH "SEE ALSO"
1238: lesskey(1)
1239:
1240: .SH WARNINGS
1241: The = command and prompts (unless changed by -P)
1242: report the line number of the line at the top of the screen,
1243: but the byte and percent of the line at the bottom of the screen.
1244: .PP
1245: If the :e command is used to name more than one file,
1246: and one of the named files has been viewed previously,
1247: the new files may be entered into the list in an unexpected order.
1248: .PP
1249: On certain older terminals (the so-called "magic cookie" terminals),
1250: search highlighting will cause an erroneous display.
1251: On such terminals, search highlighting is disabled by default
1252: to avoid possible problems.
1253: .PP
1254: In certain cases, when search highlighting is enabled and
1255: a search pattern begins with a ^,
1256: more text than the matching string may be highlighted.
1257:
1258:
1259: .SH COPYRIGHT
1260: Copyright (c) 1984,1985,1989,1994,1995 Mark Nudelman