Added all of the MH sources, including RCS files, in
[mmh] / docs / historical / mh-6.8.5 / miscellany / less-177 / less.nro
1 .TH LESS 1
2 .SH NAME
3 less \- opposite of more
4 .SH SYNOPSIS
5 .B "less -?"
6 .br
7 .B "less [-[+]aBcCdeEfHimMnNqQrsSuUw]"
8 .br
9 .B "     [-b \fIbufs\fP] [-h \fIlines\fP] [-j \fIline\fP] [-k \fIkeyfile\fP]"
10 .br
11 .B "     [-{oO} \fIlogfile\fP] [-p \fIpattern\fP] [-P \fIprompt\fP] [-t \fItag\fP]"
12 .br
13 .B "     [-T \fItagfile\fP] [-x \fItab\fP] [-y \fIlines\fP] [-[z] \fIlines\fP]"
14 .br
15 .B "     [+[+]\fIcmd\fP] [\fIfilename\fP]..."
16
17 .SH DESCRIPTION
18 .I Less
19 is a program similar to 
20 .I more
21 (1), but which allows backward movement
22 in the file as well as forward movement.
23 Also,
24 .I less
25 does not have to read the entire input file before starting,
26 so with large input files it starts up faster than text editors like
27 .I vi
28 (1).
29 .I Less
30 uses termcap (or terminfo on some systems),
31 so it can run on a variety of terminals.
32 There is even limited support for hardcopy terminals.
33 (On a hardcopy terminal, lines which should be printed at the top
34 of the screen are prefixed with an up-arrow.)
35 .PP
36 Commands are based on both
37 .I more
38 and
39 .I vi.
40 Commands may be preceded by a decimal number, 
41 called N in the descriptions below.
42 The number is used by some commands, as indicated.
43
44 .SH COMMANDS
45 In the following descriptions, ^X means control-X.
46 ESC stands for the ESCAPE key; for example ESC-v means the
47 two character sequence "ESCAPE", then "v".
48 .IP "h or H"
49 Help: display a summary of these commands.
50 If you forget all the other commands, remember this one.
51 .PP
52 .IP "SPACE or ^V or f or ^F"
53 Scroll forward N lines, default one window (see option -z below).
54 If N is more than the screen size, only the final screenful is displayed.
55 Warning: some systems use ^V as a special literalization character.
56 .PP
57 .IP "z"
58 Like SPACE, but if N is specified, it becomes the new window size.
59 .PP
60 .IP "RETURN or ^N or e or ^E or j or ^J"
61 Scroll forward N lines, default 1.
62 The entire N lines are displayed, even if N is more than the screen size.
63 .PP
64 .IP "d or ^D"
65 Scroll forward N lines, default one half of the screen size.
66 If N is specified, it becomes the new default for 
67 subsequent d and u commands.
68 .PP
69 .IP "b or ^B or ESC-v"
70 Scroll backward N lines, default one window (see option -z below).
71 If N is more than the screen size, only the final screenful is displayed.
72 .PP
73 .IP "w"
74 Like ESC-v, but if N is specified, it becomes the new window size.
75 .PP
76 .IP "y or ^Y or ^P or k or ^K"
77 Scroll backward N lines, default 1.
78 The entire N lines are displayed, even if N is more than the screen size.
79 Warning: some systems use ^Y as a special job control character.
80 .PP
81 .IP "u or ^U"
82 Scroll backward N lines, default one half of the screen size.
83 If N is specified, it becomes the new default for 
84 subsequent d and u commands.
85 .PP
86 .IP "r or ^R or ^L"
87 Repaint the screen.
88 .PP
89 .IP R
90 Repaint the screen, discarding any buffered input.
91 Useful if the file is changing while it is being viewed.
92 .PP
93 .IP "F"
94 Scroll forward, and keep trying to read when the
95 end of file is reached.
96 Normally this command would be used when already at the end of the file.
97 It is a way to monitor the tail of a file which is growing
98 while it is being viewed.
99 (The behavior is similar to the "tail -f" command.)
100 .PP
101 .IP "g or < or ESC-<"
102 Go to line N in the file, default 1 (beginning of file).
103 (Warning: this may be slow if N is large.)
104 .PP
105 .IP "G or > or ESC->"
106 Go to line N in the file, default the end of the file.
107 (Warning: this may be slow if N is large,
108 or if N is not specified and
109 standard input, rather than a file, is being read.)
110 .PP
111 .IP "p or %"
112 Go to a position N percent into the file.
113 N should be between 0 and 100.
114 (This works if standard input is being read, but only if
115 .I less
116 has already read to the end of the file.
117 It is always fast, but not always useful.)
118 .PP
119 .IP "{"
120 If a left curly bracket appears in the top line displayed
121 on the screen,
122 the { command will go to the matching right curly bracket.
123 The matching right curly bracket is positioned on the bottom
124 line of the screen.
125 If there is more than one left curly bracket on the top line,
126 a number N may be used to specify the N-th bracket on the line.
127 .PP
128 .IP "}"
129 If a right curly bracket appears in the bottom line displayed
130 on the screen,
131 the } command will go to the matching left curly bracket.
132 The matching left curly bracket is positioned on the top
133 line of the screen.
134 If there is more than one right curly bracket on the top line,
135 a number N may be used to specify the N-th bracket on the line.
136 .PP
137 .IP "("
138 Like {, but applies to parentheses rather than curly brackets.
139 .PP
140 .IP ")"
141 Like }, but applies to parentheses rather than curly brackets.
142 .PP
143 .IP "["
144 Like {, but applies to square brackets rather than curly brackets.
145 .PP
146 .IP "]"
147 Like }, but applies to square brackets rather than curly brackets.
148 .PP
149 .IP "ESC-^F"
150 Followed by two characters,
151 acts like {, but uses the two characters as open and close brackets,
152 respectively.
153 For example, "ESC ^F < >" could be used to 
154 go forward to the > which matches the < in the top displayed line.
155 .IP "ESC-^B"
156 Followed by two characters,
157 acts like }, but uses the two characters as open and close brackets,
158 respectively.
159 For example, "ESC ^B < >" could be used to 
160 go backward to the < which matches the > in the bottom displayed line.
161 .IP m
162 Followed by any lowercase letter, 
163 marks the current position with that letter.
164 .PP
165 .IP "'"
166 (Single quote.)
167 Followed by any lowercase letter, returns to the position which
168 was previously marked with that letter.
169 Followed by another single quote, returns to the position at
170 which the last "large" movement command was executed.
171 Followed by a ^ or $, jumps to the beginning or end of the
172 file respectively.
173 Marks are preserved when a new file is examined,
174 so the ' command can be used to switch between input files.
175 .PP
176 .IP "^X^X"
177 Same as single quote.
178 .PP
179 .IP /pattern
180 Search forward in the file for the N-th line containing the pattern.
181 N defaults to 1.
182 The pattern is a regular expression, as recognized by
183 .I ed.
184 The search starts at the second line displayed
185 (but see the -a and -j options, which change this).
186 .sp
187 Certain characters are special
188 if entered at the beginning of the pattern;
189 they modify the type of search rather than become part of the pattern:
190 .RS
191 .IP !
192 Search for lines which do NOT match the pattern.
193 .IP *
194 Search multiple files.
195 That is, if the search reaches the end of the current file 
196 without finding a match,
197 the search continues in the next file in the command line list.
198 .IP @
199 Begin the search at the first line of the first file
200 in the command line list,
201 regardless of what is currently displayed on the screen
202 or the settings of the -a or -j options.
203 .RE
204 .PP
205 .IP ?pattern
206 Search backward in the file for the N-th line containing the pattern.
207 The search starts at the line immediately before the top line displayed.
208 .sp
209 Certain characters are special as in the / command:
210 .RS
211 .IP !
212 Search for lines which do NOT match the pattern.
213 .IP *
214 Search multiple files.
215 That is, if the search reaches the beginning of the current file 
216 without finding a match,
217 the search continues in the previous file in the command line list.
218 .IP @
219 Begin the search at the last line of the last file
220 in the command line list,
221 regardless of what is currently displayed on the screen
222 or the settings of the -a or -j options.
223 .RE
224 .PP
225 .IP "ESC-/pattern"
226 Same as "/*".
227 .PP
228 .IP "ESC-?pattern"
229 Same as "?*".
230 .PP
231 .IP n
232 Repeat previous search, for N-th line containing the last pattern.
233 If the previous search was modified by !, the search is made for the
234 N-th line NOT containing the pattern.
235 If the previous search was modified by *, the search continues
236 in the next (or previous) file if not satisfied in the current file.
237 There is no effect if the previous search was modified by @.
238 .PP
239 .IP N
240 Repeat previous search, but in the reverse direction.
241 .PP
242 .IP "ESC-n"
243 Repeat previous search, but crossing file boundaries.
244 The effect is as if the previous search were modified by *.
245 .PP
246 .IP "ESC-N"
247 Repeat previous search, but in the reverse direction
248 and crossing file boundaries.
249 .PP
250 .IP ":e [filename]"
251 Examine a new file.
252 If the filename is missing, the "current" file (see the :n and :p commands
253 below) from the list of files in the command line is re-examined.
254 A percent sign (%) in the filename is replaced by the name of the
255 current file.  
256 A pound sign (#) is replaced by the name of the previously examined file.
257 The filename is inserted into the command line list of files
258 so that it can be seen by subsequent :n and :p commands.
259 If the filename consists of several files, they are all inserted into
260 the list of files and the first one is examined.
261 .PP
262 .IP "^X^V or E"
263 Same as :e.
264 Warning: some systems use ^V as a special literalization character.
265 .PP
266 .IP ":n"
267 Examine the next file (from the list of files given in the command line).
268 If a number N is specified, the N-th next file is examined.
269 .PP
270 .IP ":p"
271 Examine the previous file in the command line list.
272 If a number N is specified, the N-th previous file is examined.
273 .PP
274 .IP ":x"
275 Examine the first file in the command line list.
276 If a number N is specified, the N-th file in the list is examined.
277 .PP
278 .IP "= or ^G or :f"
279 Prints some information about the file being viewed,
280 including its name
281 and the line number and byte offset of the bottom line being displayed.
282 If possible, it also prints the length of the file,
283 the number of lines in the file
284 and the percent of the file above the last displayed line.
285 .PP
286 .IP \-
287 Followed by one of the command line option letters (see below),
288 this will change the setting of that option
289 and print a message describing the new setting.
290 If the option letter has a numeric value (such as -b or -h),
291 or a string value (such as -P or -t),
292 a new value may be entered after the option letter.
293 If no new value is entered, a message describing
294 the current setting is printed and nothing is changed.
295 .PP
296 .IP \-+
297 Followed by one of the command line option letters (see below),
298 this will reset the option to its default setting
299 and print a message describing the new setting.
300 (The "\-+\fIX\fP" command does the same thing
301 as "\-+\fIX\fP" on the command line.)
302 This does not work for string-valued options.
303 .PP
304 .IP \-\-
305 Followed by one of the command line option letters (see below),
306 this will reset the option to the "opposite" of its default setting
307 and print a message describing the new setting.
308 (The "\-\-\fIX\fP" command does the same thing
309 as "\-\fIX\fP" on the command line.)
310 This does not work for numeric or string-valued options.
311 .PP
312 .IP _
313 (Underscore.)
314 Followed by one of the command line option letters (see below),
315 this will print a message describing the current setting of that option.
316 The setting of the option is not changed.
317 .PP
318 .IP +cmd
319 Causes the specified cmd to be executed each time a new file is examined.
320 For example, +G causes 
321 .I less
322 to initially display each file starting at the end 
323 rather than the beginning.
324 .PP
325 .IP V
326 Prints the version number of 
327 .I less 
328 being run.
329 .PP
330 .IP "q or :q or :Q or ZZ or ESC ESC"
331 Exits
332 .I less.
333 .PP
334 The following 
335 three
336 commands may or may not be valid, depending on your particular installation.
337 .PP
338 .IP v
339 Invokes an editor to edit the current file being viewed.
340 The editor is taken from the environment variable EDITOR,
341 or defaults to "vi".
342 See also the discussion of LESSEDIT under the section on PROMPTS below.
343 .PP
344 .IP "! shell-command"
345 Invokes a shell to run the shell-command given.
346 A percent sign (%) in the command is replaced by the name of the
347 current file.  
348 A pound sign (#) is replaced by the name of the previously examined file.
349 "!!" repeats the last shell command.
350 "!" with no shell command simply invokes a shell.
351 In all cases, the shell is taken from the environment variable SHELL,
352 or defaults to "sh".
353 .PP
354 .IP "| <m> shell-command"
355 <m> represents any mark letter.
356 Pipes a section of the input file to the given shell command.
357 The section of the file to be piped is between the first line on
358 the current screen and the position marked by the letter.
359 <m> may also be ^ or $ to indicate beginning or end of file respectively.
360 If <m> is . or newline, the current screen is piped.
361 .PP
362 .SH OPTIONS
363 Command line options are described below.
364 Most options may be changed while
365 .I less 
366 is running, via the "\-" command.
367 .PP
368 Options are also taken from the environment variable "LESS".
369 For example, 
370 to avoid typing "less -options ..." each time 
371 .I less 
372 is invoked, you might tell 
373 .I csh:
374 .sp
375 setenv LESS "-options"
376 .sp
377 or if you use 
378 .I sh:
379 .sp
380 LESS="-options"; export LESS
381 .sp
382 The environment variable is parsed before the command line,
383 so command line options override the LESS environment variable.
384 If an option appears in the LESS variable, it can be reset
385 to its default on the command line by beginning the command
386 line option with "-+".
387 .sp
388 A dollar sign ($) may be used to signal the end of an option string.
389 This is important only for options like -P which take a
390 following string.
391 .IP -?
392 This option displays a summary of the commands accepted by
393 .I less
394 (the same as the h command).
395 If this option is given, all other options are ignored, and
396 .I less
397 exits after the help screen is viewed.
398 (Depending on how your shell interprets the question mark,
399 it may be necessary to quote the question mark, thus: "-\\?".)
400 .IP -a
401 Causes searches to start after the last line
402 displayed on the screen, 
403 thus skipping all lines displayed on the screen.
404 By default, searches start at the second line on the screen
405 (or after the last found line; see the -j option).
406 .IP -b\fIn\fP
407 Causes
408 .I less
409 to use a non-standard number of buffers.
410 Buffers are 1K, and by default 10 buffers are used
411 (except if data in coming from standard input; see the -B option).
412 The number \fIn\fP specifies a different number of buffers to use.
413 .IP -B
414 Disables automatic allocation of buffers,
415 so that only the default number of buffers are used.
416 If more data is read than will fit in the buffers, the oldest
417 data is discarded.
418 By default, when data is coming from standard input,
419 buffers are allocated automatically as needed
420 to avoid loss of data.
421 .IP -c
422 Causes full screen repaints to be painted from the top line down.
423 By default,
424 full screen repaints are done by scrolling from the bottom of the screen.
425 .IP -C
426 The -C option is like -c, but the screen is cleared before it is repainted.
427 .IP -d
428 The -d option suppresses the error message
429 normally displayed if the terminal is dumb;
430 that is, lacks some important capability,
431 such as the ability to clear the screen or scroll backward.
432 The -d option does not otherwise change the behavior of
433 .I less
434 on a dumb terminal).
435 .IP -e
436 Causes 
437 .I less 
438 to automatically exit
439 the second time it reaches end-of-file.
440 By default, the only way to exit 
441 .I less
442 is via the "q" command.
443 .IP -E
444 Causes 
445 .I less
446 to automatically exit the first time it reaches end-of-file.
447 .IP -f
448 Forces non-regular files to be opened.
449 (A non-regular file is a directory or a device special file.)
450 Also suppresses the warning message when a binary file is opened.
451 By default,
452 .I less
453 will refuse to open non-regular files.
454 .IP -h\fIn\fP
455 Specifies a maximum number of lines to scroll backward.
456 If it is necessary to scroll backward more than \fIn\fP lines,
457 the screen is repainted in a forward direction instead.
458 (If the terminal does not have the ability to scroll
459 backward, -h0 is implied.)
460 .IP -i
461 Causes searches to ignore case; that is,
462 uppercase and lowercase are considered identical.
463 Also, text which is overstruck or underlined can be searched for.
464 This option is ignored if any uppercase letters
465 appear in the search pattern.
466 .IP -j\fIn\fP
467 Specifies a line on the screen where "target" lines
468 are to be positioned.
469 Target lines are the object of text searches, 
470 tag searches, jumps to a line number,
471 jumps to a file percentage, and jumps to a marked position.
472 The screen line is specified by a number: the top line on the screen
473 is 1, the next is 2, and so on.
474 The number may be negative to specify a line relative to the bottom
475 of the screen: the bottom line on the screen is -1, the second
476 to the bottom is -2, and so on.
477 If the -j option is used, searches begin at the line immediately
478 after the target line.
479 For example, if "-j4" is used, the target line is the
480 fourth line on the screen, so searches begin at the fifth line
481 on the screen.
482 .IP -k\fIfilename\fP
483 Causes
484 .I less
485 to open and interpret the named file as a
486 .I lesskey
487 (1) file.
488 Multiple -k options may be specified.
489 If a file called .less exists in the user's home directory, this
490 file is also used as a
491 .I lesskey
492 file.
493 .IP -m
494 Causes 
495 .I less
496 to prompt verbosely (like \fImore\fP),
497 with the percent into the file.
498 By default,
499 .I less
500 prompts with a colon.
501 .IP -M
502 Causes 
503 .I less
504 to prompt even more verbosely than 
505 .I more.
506 .IP -n
507 Suppresses line numbers.
508 The default (to use line numbers) may cause
509 .I less
510 to run more slowly in some cases, especially with a very large input file.
511 Suppressing line numbers with the -n flag will avoid this problem.
512 Using line numbers means: the line number will be displayed in the verbose
513 prompt and in the = command,
514 and the v command will pass the current line number to the editor
515 (see also the discussion of LESSEDIT in PROMPTS below).
516 .IP -N
517 Causes a line number to be displayed at the beginning of
518 each line in the display.
519 .IP -o\fIfilename\fP
520 Causes
521 .I less
522 to copy its input to the named file as it is being viewed.
523 This applies only when the input file is a pipe,
524 not an ordinary file.
525 If the file already exists, 
526 .I less
527 will ask for confirmation before overwriting it.
528 .IP -O\fIfilename\fP
529 The -O option is like -o, but it will overwrite an existing
530 file without asking for confirmation.
531 .sp
532 If no log file has been specified,
533 the -o and -O options can be used from within 
534 .I less
535 to specify a log file.
536 Without a file name, they will simply report the name of the log file.
537 The "s" command is equivalent to specifying -o from within
538 .I less.
539 .IP -p\fIpattern\fP
540 The -p option on the command line is equivalent to 
541 specifying +/\fIpattern\fP;
542 that is, it tells
543 .I less
544 to start at the first occurence of \fIpattern\fP in the file.
545 .IP -P\fIprompt\fP
546 Provides a way to tailor the three prompt
547 styles to your own preference.
548 This option would normally be put in the LESS environment
549 variable, rather than being typed in with each 
550 .I less
551 command.
552 Such an option must either be the last option in the LESS variable,
553 or be terminated by a dollar sign.
554 -P followed by a string changes the default (short) prompt to that string.
555 -Pm changes the medium (-m) prompt to the string, and
556 -PM changes the long (-M) prompt.
557 Also, -P= changes the message printed by the = command to the given string.
558 All prompt strings consist of a sequence of 
559 letters and special escape sequences.
560 See the section on PROMPTS for more details.
561 .IP -q
562 Causes moderately "quiet" operation:
563 the terminal bell is not rung 
564 if an attempt is made to scroll past the end of the file
565 or before the beginning of the file.
566 If the terminal has a "visual bell", it is used instead.
567 The bell will be rung on certain other errors,
568 such as typing an invalid character.
569 The default is to ring the terminal bell in all such cases.
570 .IP -Q
571 Causes totally "quiet" operation:
572 the terminal bell is never rung.
573 .IP -r
574 Causes "raw" control characters to be displayed.
575 The default is to display control characters using the caret notation;
576 for example, a control-A (octal 001) is displayed as "^A".
577 Warning: when the -r flag is used,
578 .I less
579 cannot keep track of the actual appearance of the screen
580 (since this depends on how the screen responds to
581 each type of control character).
582 Thus, various display problems may result,
583 such as long lines being split in the wrong place.
584 .IP -s
585 Causes consecutive blank lines to be squeezed into a single blank line.
586 This is useful when viewing
587 .I nroff
588 output.
589 .IP -S
590 Causes lines longer than the screen width to be
591 chopped rather than folded.
592 That is, the remainder of a long line is simply discarded.
593 The default is to fold long lines; that is, display the remainder
594 on the next line.
595 .IP -t\fItag\fP
596 The -t option, followed immediately by a TAG,
597 will edit the file containing that tag.
598 For this to work, there must be a file called "tags" in the
599 current directory, which was previously built by the 
600 .I ctags
601 (1) command.
602 This option may also be specified from within 
603 .I less 
604 (using the \- command) as a way of examining a new file.
605 The command ":t" is equivalent to specifying -t from within
606 .I less.
607 .IP -T\fItagsfile\fP
608 Specifies a tags file to be used instead of "tags".
609 .IP -u
610 Causes backspaces and carriage returns to be treated as printable characters;
611 that is, they are sent to the terminal when they appear in the input.
612 .IP -U
613 Causes backspaces and carriage returns to be treated as control characters;
614 that is, they are handled as specified by the -r option.
615 .sp
616 By default, if neither -u nor -U is given,
617 backspaces which appear adjacent to an underscore character
618 are treated specially:
619 the underlined text is displayed 
620 using the terminal's hardware underlining capability.
621 Also, backspaces which appear between two identical characters
622 are treated specially: 
623 the overstruck text is printed 
624 using the terminal's hardware boldface capability.
625 Other backspaces are deleted, along with the preceding character.
626 Carriage returns immediately followed by a newline are deleted.
627 Other carriage returns are handled as specified by the -r option.
628 .IP -w
629 Causes blank lines to be used to represent lines
630 past the end of the file.
631 By default,
632 a tilde character is used.
633 .IP -x\fIn\fP
634 Sets tab stops every \fIn\fP positions.
635 The default for \fIn\fP is 8.
636 .IP -y\fIn\fP
637 Specifies a maximum number of lines to scroll forward.
638 If it is necessary to scroll forward more than \fIn\fP lines,
639 the screen is repainted instead.
640 The -c or -C option may be used to repaint from the top of
641 the screen if desired.
642 By default, any forward movement causes scrolling.
643 .IP -[z]\fIn\fP
644 Changes the default scrolling window size to \fIn\fP lines.
645 The default is one screenful.
646 The z and w commands can also be used to change the window size.
647 The "z" may be omitted, as in "-\fIn\fP" for compatibility with
648 .I more.
649 .IP +
650 If a command line option begins with \fB+\fP,
651 the remainder of that option is taken to be an initial command to
652 .I less.
653 For example, +G tells
654 .I less
655 to start at the end of the file rather than the beginning,
656 and +/xyz tells it to start at the first occurrence of "xyz" in the file.
657 As a special case, +<number> acts like +<number>g; 
658 that is, it starts the display at the specified line number
659 (however, see the caveat under the "g" command above).
660 If the option starts with ++, the initial command applies to
661 every file being viewed, not just the first one.
662 The + command described previously
663 may also be used to set (or change) an initial command for every file.
664
665 .SH "KEY BINDINGS"
666 You may define your own 
667 .I less
668 commands by using the program 
669 .I lesskey
670 (1)
671 to create a file called ".less" in your home directory.
672 This file specifies a set of command keys and an action
673 associated with each key.
674 See the
675 .I lesskey
676 manual page for more details.
677
678 .SH "NATIONAL CHARACTER SETS"
679 There are three types of characters in the input file:
680 .IP "normal characters"
681 can be displayed directly to the screen.
682 .IP "control characters"
683 should not be displayed directly, but are expected to be found
684 in ordinary text files (such as backspace and tab).
685 .IP "binary characters"
686 cannot be displayed directly and are not expected to be found
687 in text files.
688 .PP
689 By default, 
690 .I less
691 uses the ASCII character set.
692 In the ASCII character set, characters
693 with values between 128 and 255 are treated as binary.
694 The LESSCHARSET environment variable may be used to select
695 another character set.
696 If it is set to the value "latin1",
697 the ISO 8859/1 character set is assumed.
698 Latin-1 is the same as ASCII, except characters between 128 and 255 are
699 treated as normal characters.
700 The only valid values for LESSCHARSET currently are "ascii" and "latin1".
701 .PP
702 In special cases, it may be desired to tailor
703 .I less
704 to use a character set other than the ones definable by LESSCHARSET.
705 In this case, the environment variable LESSCHARDEF can be used
706 to define a character set.
707 It should be set to a string where each character in the string represents
708 one character in the character set.
709 The character "." is used for a normal character, "c" for control,
710 and "b" for binary.
711 A decimal number may be used for repetition.
712 For example, "bccc4b." would mean character 0 is binary,
713 1, 2 and 3 are control, 4, 5, 6 and 7 are binary, and 8 is normal.
714 All characters after the last are taken to be the same as the last,
715 so characters 9 through 255 would be normal.
716 (This is an example, and does not necessarily 
717 represent any real character set.)
718 .PP
719 Setting LESSCHARDEF to "8bcccbcc18b95.b" is the same as setting
720 LESSCHARSET to "ascii".
721 Setting LESSCHARDEF to "8bcccbcc18b95.33b." is the same as setting
722 LESSCHARSET to "latin1".
723 .PP
724 Control and binary characters are displayed in blinking mode.
725 Each such character is displayed in caret notation if possible
726 (e.g. ^A for control-A).  Caret notation is used only if 
727 inverting the 0100 bit results in a normal printable character.
728 Otherwise, the character is displayed as an octal number preceded
729 by a backslash.
730 This octal format can be changed by 
731 setting the LESSBINFMT environment variable
732 to a printf-style format string; the default is '\\%o'.
733 The blinking mode display of control and binary characters can
734 be changed or disabled by preceding the LESSBINFMT format 
735 string with a "*" and one character to select the mode:
736 "*k" is blinking, "*d" is bold, "*u" is underlined,
737 and "*n" is normal (no special display attribute).
738 For example, if LESSBINFMT is "*u[%x]", binary characters
739 are displayed in underlined hexadecimal surrounded by brackets.
740
741 .SH "PROMPTS"
742 The -P option allows you to tailor the prompt to your preference.
743 The string given to the -P option replaces the specified prompt string.
744 Certain characters in the string are interpreted specially.
745 The prompt mechanism is rather complicated to provide flexibility,
746 but the ordinary user need not understand the details of constructing
747 personalized prompt strings.
748 .sp
749 A percent sign followed by a single character is expanded
750 according to what the following character is:
751 .IP "%b\fIX\fP"
752 Replaced by the byte offset into the current input file.
753 The b is followed by a single character (shown as \fIX\fP above)
754 which specifies the line whose byte offset is to be used.
755 If the character is a "t", the byte offset of the top line in the
756 display is used,
757 an "m" means use the middle line,
758 a "b" means use the bottom line,
759 a "B" means use the line just after the bottom line,
760 and a "j" means use the "target" line, as specified by the -j option.
761 .IP "%B"
762 Replaced by the size of the current input file.
763 .IP "%E"
764 Replaced by the name of the editor (from the EDITOR environment variable).
765 See the discussion of the LESSEDIT feature below.
766 .IP "%f"
767 Replaced by the name of the current input file.
768 .IP "%i"
769 Replaced by the index of the current file in the list of
770 input files.
771 .IP "%l\fIX\fP"
772 Replaced by the line number of a line in the input file.
773 The line to be used is determined by the \fIX\fP, as with the %b option.
774 .IP "%L"
775 Replaced by the line number of the last line in the input file.
776 .IP "%m"
777 Replaced by the total number of input files.
778 .IP "%p\fIX\fP"
779 Replaced by the percent into the current input file.
780 The line used is determined by the \fIX\fP as with the %b option.
781 .IP "%s"
782 Same as %B.
783 .IP "%t"
784 Causes any trailing spaces to be removed.
785 Usually used at the end of the string, but may appear anywhere.
786 .IP "%x"
787 Replaced by the name of the next input file in the list.
788 .PP
789 If any item is unknown (for example, the file size if input
790 is a pipe), a question mark is printed instead.
791 .PP
792 The format of the prompt string can be changed
793 depending on certain conditions.
794 A question mark followed by a single character acts like an "IF":
795 depending on the following character, a condition is evaluated.
796 If the condition is true, any characters following the question mark
797 and condition character, up to a period, are included in the prompt.
798 If the condition is false, such characters are not included.
799 A colon appearing between the question mark and the
800 period can be used to establish an "ELSE": any characters between
801 the colon and the period are included in the string if and only if
802 the IF condition is false.
803 Condition characters (which follow a question mark) may be:
804 .IP "?a"
805 True if any characters have been included in the prompt so far.
806 .IP "?b\fIX\fP"
807 True if the byte offset of the specified line is known.
808 .IP "?B"
809 True if the size of current input file is known.
810 .IP "?e"
811 True if at end-of-file.
812 .IP "?f"
813 True if there is an input filename
814 (that is, if input is not a pipe).
815 .IP "?l\fIX\fP"
816 True if the line number of the specified line is known.
817 .IP "?L"
818 True if the line number of the last line in the file is known.
819 .IP "?m"
820 True if there is more than one input file.
821 .IP "?n"
822 True if this is the first prompt in a new input file.
823 .IP "?p\fIX\fP"
824 True if the percent into the current input file
825 of the specified line is known.
826 .IP "?s"
827 Same as "?B".
828 .IP "?x"
829 True if there is a next input file
830 (that is, if the current input file is not the last one).
831 .PP
832 Any characters other than the special ones
833 (question mark, colon, period, percent, and backslash)
834 become literally part of the prompt.
835 Any of the special characters may be included in the prompt literally
836 by preceding it with a backslash.
837 .PP
838 Some examples:
839 .sp
840 ?f%f:Standard input.
841 .sp
842 This prompt prints the filename, if known;
843 otherwise the string "Standard input".
844 .sp
845 ?f%f .?ltLine %lt:?pt%pt\\%:?btByte %bt:-...
846 .sp
847 This prompt would print the filename, if known.
848 The filename is followed by the line number, if known,
849 otherwise the percent if known, otherwise the byte offset if known.
850 Otherwise, a dash is printed.
851 Notice how each question mark has a matching period,
852 and how the % after the %pt
853 is included literally by escaping it with a backslash.
854 .sp
855 ?n?f%f\ .?m(file\ %i\ of\ %m)\ ..?e(END)\ ?x-\ Next\\:\ %x..%t
856 .sp
857 This prints the filename if this is the first prompt in a file,
858 followed by the "file N of N" message if there is more
859 than one input file.
860 Then, if we are at end-of-file, the string "(END)" is printed
861 followed by the name of the next file, if there is one.
862 Finally, any trailing spaces are truncated.
863 This is the default prompt.
864 For reference, here are the defaults for
865 the other two prompts (-m and -M respectively).
866 Each is broken into two lines here for readability only.
867 .nf
868 .sp
869 ?n?f%f\ .?m(file\ %i\ of\ %m)\ ..?e(END)\ ?x-\ Next\\:\ %x.:
870         ?pB%pB\\%:byte\ %bB?s/%s...%t
871 .sp
872 ?f%f\ .?n?m(file\ %i\ of\ %m)\ ..?ltline\ %lt?L/%L.\ :byte\ %bB?s/%s.\ .
873         ?e(END)\ ?x-\ Next\\:\ %x.:?pB%pB\\%..%t
874 .sp
875 .fi
876 And here is the default message produced by the = command:
877 .nf
878 .sp
879 ?f%f\ .?m(file\ %i\ of\ %m)\ .?ltline\ %lt?L/%L.\ .
880         byte\ %bB?s/%s.\ ?e(END)\ :?pB%pB\\%..%t
881 .fi
882 .PP
883 The prompt expansion features are also used for another purpose:
884 if an environment variable LESSEDIT is defined, it is used
885 as the command to be executed when the v command is invoked.
886 The LESSEDIT string is expanded in the same way as the prompt strings.
887 The default value for LESSEDIT is:
888 .nf
889 .sp
890         %E\ ?lm+%lm.\ %f
891 .sp
892 .fi
893 Note that this expands to the editor name, followed by a + and the
894 line number, followed by the file name.
895 If your editor does not accept the "+linenumber" syntax, or has other
896 differences in invocation syntax, the LESSEDIT variable can be 
897 changed to modify this default.
898
899 .SH "ENVIRONMENT VARIABLES"
900 .IP COLUMNS
901 Sets the number of columns on the screen.
902 Takes precedence over the number of columns specified by the TERM variable.
903 .IP EDITOR
904 The name of the editor (used for the v command).
905 .IP HOME
906 Name of the user's home directory (used to find a .less file).
907 .IP LESS
908 Flags which are passed to 
909 .I less
910 automatically.
911 .IP LESSBINFMT
912 Format for displaying non-printable, non-control characters.
913 .IP LESSCHARDEF
914 Defines a character set.
915 .IP LESSCHARSET
916 Selects a predefined character set.
917 .IP LESSEDIT
918 Editor prototype string (used for the v command).
919 See discussion under PROMPTS.
920 .IP LESSHELP
921 Name of the help file.
922 .IP LINES
923 Sets the number of lines on the screen.
924 Takes precedence over the number of lines specified by the TERM variable.
925 .IP SHELL
926 The shell used to execute the ! command, as well as to expand filenames.
927 .IP TERM
928 The type of terminal on which
929 .I less
930 is being run.
931
932 .SH "SEE ALSO"
933 lesskey(1)
934
935 .SH WARNINGS
936 The = command and prompts (unless changed by -P)
937 report the line number of the line at the top of the screen,
938 but the byte and percent of the line at the bottom of the screen.
939 .PP
940 If the :e command is used to name more than one file,
941 and one of the named files has been viewed previously,
942 the new files may be entered into the list in an unexpected order.
943 .PP
944 The handling of national character sets is nonstandard as well as
945 insufficient for multibyte characters.
946 It will probably change in a later release.