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