Upgrade to less version 403.
[dragonfly.git] / contrib / less-394 / less.nro
1 .TH LESS 1 "Version 394: 03 Dec 2005"
2 .SH NAME
3 less \- opposite of more
4 .SH SYNOPSIS
5 .B "less \-?"
6 .br
7 .B "less \-\-help"
8 .br
9 .B "less \-V"
10 .br
11 .B "less \-\-version"
12 .br
13 .B "less [\-[+]aBcCdeEfFgGiIJKLmMnNqQrRsSuUVwWX~]"
14 .br
15 .B "     [\-b \fIspace\fP] [\-h \fIlines\fP] [\-j \fIline\fP] [\-k \fIkeyfile\fP]"
16 .br
17 .B "     [\-{oO} \fIlogfile\fP] [\-p \fIpattern\fP] [\-P \fIprompt\fP] [\-t \fItag\fP]"
18 .br
19 .B "     [\-T \fItagsfile\fP] [\-x \fItab\fP,...] [\-y \fIlines\fP] [\-[z] \fIlines\fP]"
20 .br
21 .B "     [\-# \fIshift\fP] [+[+]\fIcmd\fP] [\-\-] [\fIfilename\fP]..."
22 .br
23 (See the OPTIONS section for alternate option syntax with long option names.)
24
25 .SH DESCRIPTION
26 .I Less
27 is a program similar to 
28 .I more
29 (1), but which allows backward movement
30 in the file as well as forward movement.
31 Also,
32 .I less
33 does not have to read the entire input file before starting,
34 so with large input files it starts up faster than text editors like
35 .I vi
36 (1).
37 .I Less
38 uses termcap (or terminfo on some systems),
39 so it can run on a variety of terminals.
40 There is even limited support for hardcopy terminals.
41 (On a hardcopy terminal, lines which should be printed at the top
42 of the screen are prefixed with a caret.)
43 .PP
44 Commands are based on both
45 .I more
46 and
47 .I vi.
48 Commands may be preceded by a decimal number, 
49 called N in the descriptions below.
50 The number is used by some commands, as indicated.
51
52 .SH COMMANDS
53 In the following descriptions, ^X means control-X.
54 ESC stands for the ESCAPE key; for example ESC-v means the
55 two character sequence "ESCAPE", then "v".
56 .IP "h or H"
57 Help: display a summary of these commands.
58 If you forget all the other commands, remember this one.
59 .IP "SPACE or ^V or f or ^F"
60 Scroll forward N lines, default one window (see option \-z below).
61 If N is more than the screen size, only the final screenful is displayed.
62 Warning: some systems use ^V as a special literalization character.
63 .IP "z"
64 Like SPACE, but if N is specified, it becomes the new window size.
65 .IP "ESC-SPACE"
66 Like SPACE, but scrolls a full screenful, even if it reaches
67 end-of-file in the process.
68 .IP "RETURN or ^N or e or ^E or j or ^J"
69 Scroll forward N lines, default 1.
70 The entire N lines are displayed, even if N is more than the screen size.
71 .IP "d or ^D"
72 Scroll forward N lines, default one half of the screen size.
73 If N is specified, it becomes the new default for 
74 subsequent d and u commands.
75 .IP "b or ^B or ESC-v"
76 Scroll backward N lines, default one window (see option \-z below).
77 If N is more than the screen size, only the final screenful is displayed.
78 .IP "w"
79 Like ESC-v, but if N is specified, it becomes the new window size.
80 .IP "y or ^Y or ^P or k or ^K"
81 Scroll backward N lines, default 1.
82 The entire N lines are displayed, even if N is more than the screen size.
83 Warning: some systems use ^Y as a special job control character.
84 .IP "u or ^U"
85 Scroll backward N lines, default one half of the screen size.
86 If N is specified, it becomes the new default for 
87 subsequent d and u commands.
88 .IP "ESC-) or RIGHTARROW"
89 Scroll horizontally right N characters, default half the screen width
90 (see the \-# option).
91 If a number N is specified, it becomes the default for future RIGHTARROW
92 and LEFTARROW commands.
93 While the text is scrolled, it acts as though the \-S option
94 (chop lines) were in effect.
95 .IP "ESC-( or LEFTARROW"
96 Scroll horizontally left N characters, default half the screen width
97 (see the \-# option).
98 If a number N is specified, it becomes the default for future RIGHTARROW
99 and LEFTARROW commands.
100 .IP "r or ^R or ^L"
101 Repaint the screen.
102 .IP R
103 Repaint the screen, discarding any buffered input.
104 Useful if the file is changing while it is being viewed.
105 .IP "F"
106 Scroll forward, and keep trying to read when the
107 end of file is reached.
108 Normally this command would be used when already at the end of the file.
109 It is a way to monitor the tail of a file which is growing
110 while it is being viewed.
111 (The behavior is similar to the "tail \-f" command.)
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 .IP "G or > or ESC->"
116 Go to line N in the file, default the end of the file.
117 (Warning: this may be slow if N is large,
118 or if N is not specified and
119 standard input, rather than a file, is being read.)
120 .IP "p or %"
121 Go to a position N percent into the file.
122 N should be between 0 and 100.
123 .IP "{"
124 If a left curly bracket appears in the top line displayed
125 on the screen,
126 the { command will go to the matching right curly bracket.
127 The matching right curly bracket is positioned on the bottom
128 line of the screen.
129 If there is more than one left curly bracket on the top line,
130 a number N may be used to specify the N-th bracket on the line.
131 .IP "}"
132 If a right curly bracket appears in the bottom line displayed
133 on the screen,
134 the } command will go to the matching left curly bracket.
135 The matching left curly bracket is positioned on the top
136 line of the screen.
137 If there is more than one right curly bracket on the top line,
138 a number N may be used to specify the N-th bracket on the line.
139 .IP "("
140 Like {, but applies to parentheses rather than curly brackets.
141 .IP ")"
142 Like }, but applies to parentheses rather than curly brackets.
143 .IP "["
144 Like {, but applies to square brackets rather than curly brackets.
145 .IP "]"
146 Like }, but applies to square brackets rather than curly brackets.
147 .IP "ESC-^F"
148 Followed by two characters,
149 acts like {, but uses the two characters as open and close brackets,
150 respectively.
151 For example, "ESC ^F < >" could be used to 
152 go forward to the > which matches the < in the top displayed line.
153 .IP "ESC-^B"
154 Followed by two characters,
155 acts like }, but uses the two characters as open and close brackets,
156 respectively.
157 For example, "ESC ^B < >" could be used to 
158 go backward to the < which matches the > in the bottom displayed line.
159 .IP m
160 Followed by any lowercase letter, 
161 marks the current position with that letter.
162 .IP "'"
163 (Single quote.)
164 Followed by any lowercase letter, returns to the position which
165 was previously marked with that letter.
166 Followed by another single quote, returns to the position at
167 which the last "large" movement command was executed.
168 Followed by a ^ or $, jumps to the beginning or end of the
169 file respectively.
170 Marks are preserved when a new file is examined,
171 so the ' command can be used to switch between input files.
172 .IP "^X^X"
173 Same as single quote.
174 .IP /pattern
175 Search forward in the file for the N-th line containing the pattern.
176 N defaults to 1.
177 The pattern is a regular expression, as recognized by
178 the regular expression library supplied by your system.
179 The search starts at the second line displayed
180 (but see the \-a and \-j options, which change this).
181 .sp
182 Certain characters are special
183 if entered at the beginning of the pattern;
184 they modify the type of search rather than become part of the pattern:
185 .RS
186 .IP "^N or !"
187 Search for lines which do NOT match the pattern.
188 .IP "^E or *"
189 Search multiple files.
190 That is, if the search reaches the END of the current file 
191 without finding a match,
192 the search continues in the next file in the command line list.
193 .IP "^F or @"
194 Begin the search at the first line of the FIRST file
195 in the command line list,
196 regardless of what is currently displayed on the screen
197 or the settings of the \-a or \-j options.
198 .IP "^K"
199 Highlight any text which matches the pattern on the current screen, 
200 but don't move to the first match (KEEP current position).
201 .IP "^R"
202 Don't interpret regular expression metacharacters;
203 that is, do a simple textual comparison.
204 .RE
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 "^N or !"
212 Search for lines which do NOT match the pattern.
213 .IP "^E or *"
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 "^F or @"
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 .IP "^K"
224 As in forward searches.
225 .IP "^R"
226 As in forward searches.
227 .RE
228 .IP "ESC-/pattern"
229 Same as "/*".
230 .IP "ESC-?pattern"
231 Same as "?*".
232 .IP n
233 Repeat previous search, for N-th line containing the last pattern.
234 If the previous search was modified by ^N, the search is made for the
235 N-th line NOT containing the pattern.
236 If the previous search was modified by ^E, the search continues
237 in the next (or previous) file if not satisfied in the current file.
238 If the previous search was modified by ^R, the search is done
239 without using regular expressions.
240 There is no effect if the previous search was modified by ^F or ^K.
241 .IP N
242 Repeat previous search, but in the reverse direction.
243 .IP "ESC-n"
244 Repeat previous search, but crossing file boundaries.
245 The effect is as if the previous search were modified by *.
246 .IP "ESC-N"
247 Repeat previous search, but in the reverse direction
248 and crossing file boundaries.
249 .IP "ESC-u"
250 Undo search highlighting.
251 Turn off highlighting of strings matching the current search pattern. 
252 If highlighting is already off because of a previous ESC-u command,
253 turn highlighting back on.
254 Any search command will also turn highlighting back on.
255 (Highlighting can also be disabled by toggling the \-G option;
256 in that case search commands do not turn highlighting back on.)
257 .IP ":e [filename]"
258 Examine a new file.
259 If the filename is missing, the "current" file (see the :n and :p commands
260 below) from the list of files in the command line is re-examined.
261 A percent sign (%) in the filename is replaced by the name of the
262 current file.  
263 A pound sign (#) is replaced by the name of the previously examined file.
264 However, two consecutive percent signs are simply 
265 replaced with a single percent sign.  
266 This allows you to enter a filename that contains a percent sign
267 in the name.
268 Similarly, two consecutive pound signs are replaced with a single pound sign.
269 The filename is inserted into the command line list of files
270 so that it can be seen by subsequent :n and :p commands.
271 If the filename consists of several files, they are all inserted into
272 the list of files and the first one is examined.
273 If the filename contains one or more spaces,
274 the entire filename should be enclosed in double quotes
275 (also see the \-" option).
276 .IP "^X^V or E"
277 Same as :e.
278 Warning: some systems use ^V as a special literalization character.
279 On such systems, you may not be able to use ^V.
280 .IP ":n"
281 Examine the next file (from the list of files given in the command line).
282 If a number N is specified, the N-th next file is examined.
283 .IP ":p"
284 Examine the previous file in the command line list.
285 If a number N is specified, the N-th previous file is examined.
286 .IP ":x"
287 Examine the first file in the command line list.
288 If a number N is specified, the N-th file in the list is examined.
289 .IP ":d"
290 Remove the current file from the list of files.
291 .IP "t"
292 Go to the next tag, if there were more than one matches for the current tag.
293 See the \-t option for more details about tags.
294 .IP "T"
295 Go to the previous tag, if there were more than one matches for the current tag.
296 .IP "= or ^G or :f"
297 Prints some information about the file being viewed,
298 including its name
299 and the line number and byte offset of the bottom line being displayed.
300 If possible, it also prints the length of the file,
301 the number of lines in the file
302 and the percent of the file above the last displayed line.
303 .IP \-
304 Followed by one of the command line option letters (see OPTIONS below),
305 this will change the setting of that option
306 and print a message describing the new setting.
307 If a ^P (CONTROL-P) is entered immediately after the dash,
308 the setting of the option is changed but no message is printed.
309 If the option letter has a numeric value (such as \-b or \-h),
310 or a string value (such as \-P or \-t),
311 a new value may be entered after the option letter.
312 If no new value is entered, a message describing
313 the current setting is printed and nothing is changed.
314 .IP \-\-
315 Like the \- command, but takes a long option name (see OPTIONS below)
316 rather than a single option letter.
317 You must press RETURN after typing the option name.
318 A ^P immediately after the second dash suppresses printing of a 
319 message describing the new setting, as in the \- command.
320 .IP \-+
321 Followed by one of the command line option letters
322 this will reset the option to its default setting
323 and print a message describing the new setting.
324 (The "\-+\fIX\fP" command does the same thing
325 as "\-+\fIX\fP" on the command line.)
326 This does not work for string-valued options.
327 .IP \-\-+
328 Like the \-+ command, but takes a long option name
329 rather than a single option letter.
330 .IP \-!
331 Followed by one of the command line option letters,
332 this will reset the option to the "opposite" of its default setting
333 and print a message describing the new setting.
334 This does not work for numeric or string-valued options.
335 .IP \-\-!
336 Like the \-! command, but takes a long option name
337 rather than a single option letter.
338 .IP _
339 (Underscore.)
340 Followed by one of the command line option letters,
341 this will print a message describing the current setting of that option.
342 The setting of the option is not changed.
343 .IP __
344 (Double underscore.)
345 Like the _ (underscore) command, but takes a long option name
346 rather than a single option letter.
347 You must press RETURN after typing the option name.
348 .IP +cmd
349 Causes the specified cmd to be executed each time a new file is examined.
350 For example, +G causes 
351 .I less
352 to initially display each file starting at the end 
353 rather than the beginning.
354 .IP V
355 Prints the version number of 
356 .I less 
357 being run.
358 .IP "q or Q or :q or :Q or ZZ"
359 Exits
360 .I less.
361 .PP
362 The following 
363 four
364 commands may or may not be valid, depending on your particular installation.
365 .PP
366 .IP v
367 Invokes an editor to edit the current file being viewed.
368 The editor is taken from the environment variable VISUAL if defined,
369 or EDITOR if VISUAL is not defined,
370 or defaults to "vi" if neither VISUAL nor EDITOR is defined.
371 See also the discussion of LESSEDIT under the section on PROMPTS below.
372 .IP "! shell-command"
373 Invokes a shell to run the shell-command given.
374 A percent sign (%) in the command is replaced by the name of the
375 current file.  
376 A pound sign (#) is replaced by the name of the previously examined file.
377 "!!" repeats the last shell command.
378 "!" with no shell command simply invokes a shell.
379 On Unix systems, the shell is taken from the environment variable SHELL,
380 or defaults to "sh".
381 On MS-DOS and OS/2 systems, the shell is the normal command processor.
382 .IP "| <m> shell-command"
383 <m> represents any mark letter.
384 Pipes a section of the input file to the given shell command.
385 The section of the file to be piped is between the first line on
386 the current screen and the position marked by the letter.
387 <m> may also be ^ or $ to indicate beginning or end of file respectively.
388 If <m> is . or newline, the current screen is piped.
389 .IP "s filename"
390 Save the input to a file.
391 This only works if the input is a pipe, not an ordinary file.
392 .PP
393 .SH OPTIONS
394 Command line options are described below.
395 Most options may be changed while
396 .I less 
397 is running, via the "\-" command.
398 .PP
399 Most options may be given in one of two forms: 
400 either a dash followed by a single letter,
401 or two dashes followed by a long option name.
402 A long option name may be abbreviated as long as
403 the abbreviation is unambiguous.
404 For example, \-\-quit-at-eof may be abbreviated \-\-quit, but not
405 --qui, since both \-\-quit-at-eof and \-\-quiet begin with \-\-qui.
406 Some long option names are in uppercase, such as \-\-QUIT-AT-EOF, as
407 distinct from \-\-quit-at-eof.
408 Such option names need only have their first letter capitalized;
409 the remainder of the name may be in either case.
410 For example, \-\-Quit-at-eof is equivalent to \-\-QUIT-AT-EOF.
411 .PP
412 Options are also taken from the environment variable "LESS".
413 For example, 
414 to avoid typing "less \-options ..." each time 
415 .I less 
416 is invoked, you might tell 
417 .I csh:
418 .sp
419 setenv LESS "-options"
420 .sp
421 or if you use 
422 .I sh:
423 .sp
424 LESS="-options"; export LESS
425 .sp
426 On MS-DOS, you don't need the quotes, but you should replace any 
427 percent signs in the options string by double percent signs.
428 .sp
429 The environment variable is parsed before the command line,
430 so command line options override the LESS environment variable.
431 If an option appears in the LESS variable, it can be reset
432 to its default value on the command line by beginning the command
433 line option with "\-+".
434 .sp
435 For options like \-P or \-D which take a following string,
436 a dollar sign ($) must be used to signal the end of the string.
437 For example, to set two \-D options on MS-DOS, you must have
438 a dollar sign between them, like this:
439 .sp
440 LESS="-Dn9.1$-Ds4.1"
441 .sp
442 .IP "\-? or \-\-help"
443 This option displays a summary of the commands accepted by
444 .I less
445 (the same as the h command).
446 (Depending on how your shell interprets the question mark,
447 it may be necessary to quote the question mark, thus: "\-\e?".)
448 .IP "\-a or \-\-search-skip-screen"
449 Causes searches to start after the last line
450 displayed on the screen, 
451 thus skipping all lines displayed on the screen.
452 By default, searches start at the second line on the screen
453 (or after the last found line; see the \-j option).
454 .IP "\-b\fIn\fP or \-\-buffers=\fIn\fP"
455 Specifies the amount of buffer space
456 .I less
457 will use for each file, in units of kilobytes (1024 bytes).
458 By default 64K of buffer space is used for each file
459 (unless the file is a pipe; see the \-B option).
460 The \-b option specifies instead that \fIn\fP kilobytes of 
461 buffer space should be used for each file.
462 If \fIn\fP is \-1, buffer space is unlimited; that is,
463 the entire file is read into memory.
464 .IP "\-B or \-\-auto-buffers"
465 By default, when data is read from a pipe,
466 buffers are allocated automatically as needed.
467 If a large amount of data is read from the pipe, this can cause
468 a large amount of memory to be allocated.
469 The \-B option disables this automatic allocation of buffers for pipes,
470 so that only 64K 
471 (or the amount of space specified by the \-b option)
472 is used for the pipe.
473 Warning: use of \-B can result in erroneous display, since only the
474 most recently viewed part of the file is kept in memory; 
475 any earlier data is lost.
476 .IP "\-c or \-\-clear-screen"
477 Causes full screen repaints to be painted from the top line down.
478 By default,
479 full screen repaints are done by scrolling from the bottom of the screen.
480 .IP "\-C or \-\-CLEAR-SCREEN"
481 The \-C option is like \-c, but the screen is cleared before it is repainted.
482 .IP "\-d or \-\-dumb"
483 The \-d option suppresses the error message
484 normally displayed if the terminal is dumb;
485 that is, lacks some important capability,
486 such as the ability to clear the screen or scroll backward.
487 The \-d option does not otherwise change the behavior of
488 .I less
489 on a dumb terminal.
490 .IP "\-D\fBx\fP\fIcolor\fP or \-\-color=\fBx\fP\fIcolor\fP"
491 [MS-DOS only]
492 Sets the color of the text displayed.
493 \fBx\fP is a single character which selects the type of text whose color is 
494 being set: n=normal, s=standout, d=bold, u=underlined, k=blink.
495 \fIcolor\fP is a pair of numbers separated by a period.  
496 The first number selects the foreground color and the second selects 
497 the background color of the text.
498 A single number \fIN\fP is the same as \fIN.0\fP.
499 .IP "\-e or \-\-quit-at-eof"
500 Causes 
501 .I less 
502 to automatically exit
503 the second time it reaches end-of-file.
504 By default, the only way to exit 
505 .I less
506 is via the "q" command.
507 .IP "\-E or \-\-QUIT-AT-EOF"
508 Causes 
509 .I less
510 to automatically exit the first time it reaches end-of-file.
511 .IP "\-f or \-\-force"
512 Forces non-regular files to be opened.
513 (A non-regular file is a directory or a device special file.)
514 Also suppresses the warning message when a binary file is opened.
515 By default,
516 .I less
517 will refuse to open non-regular files.
518 .IP "\-F or \-\-quit-if-one-screen"
519 Causes
520 .I less
521 to automatically exit
522 if the entire file can be displayed on the first screen.
523 .IP "\-g or \-\-hilite-search"
524 Normally, 
525 .I less 
526 will highlight ALL strings which match the last search command.
527 The \-g option changes this behavior to highlight only the particular string 
528 which was found by the last search command.
529 This can cause 
530 .I less 
531 to run somewhat faster than the default.
532 .IP "\-G or \-\-HILITE-SEARCH"
533 The \-G option suppresses all highlighting of strings found by search commands.
534 .IP "\-h\fIn\fP or \-\-max-back-scroll=\fIn\fP"
535 Specifies a maximum number of lines to scroll backward.
536 If it is necessary to scroll backward more than \fIn\fP lines,
537 the screen is repainted in a forward direction instead.
538 (If the terminal does not have the ability to scroll
539 backward, \-h0 is implied.)
540 .IP "\-i or \-\-ignore-case"
541 Causes searches to ignore case; that is,
542 uppercase and lowercase are considered identical.
543 This option is ignored if any uppercase letters
544 appear in the search pattern; 
545 in other words,
546 if a pattern contains uppercase letters, then that search does not ignore case.
547 .IP "\-I or \-\-IGNORE-CASE"
548 Like \-i, but searches ignore case even if 
549 the pattern contains uppercase letters.
550 .IP "\-j\fIn\fP or \-\-jump-target=\fIn\fP"
551 Specifies a line on the screen where the "target" line
552 is to be positioned.
553 A target line is the object of a text search, 
554 tag search, jump to a line number,
555 jump to a file percentage, or jump to a marked position.
556 The screen line is specified by a number: the top line on the screen
557 is 1, the next is 2, and so on.
558 The number may be negative to specify a line relative to the bottom
559 of the screen: the bottom line on the screen is \-1, the second
560 to the bottom is \-2, and so on.
561 If the \-j option is used, searches begin at the line immediately
562 after the target line.
563 For example, if "\-j4" is used, the target line is the
564 fourth line on the screen, so searches begin at the fifth line
565 on the screen.
566 .IP "\-J or \-\-status-column"
567 Displays a status column at the left edge of the screen.
568 The status column shows the lines that matched the current search.
569 The status column is also used if the \-w or \-W option is in effect.
570 .IP "\-k\fIfilename\fP or \-\-lesskey-file=\fIfilename\fP"
571 Causes
572 .I less
573 to open and interpret the named file as a
574 .I lesskey
575 (1) file.
576 Multiple \-k options may be specified.
577 If the LESSKEY or LESSKEY_SYSTEM environment variable is set, or
578 if a lesskey file is found in a standard place (see KEY BINDINGS),
579 it is also used as a 
580 .I lesskey
581 file.
582 .IP "\-K or \-\-quit-on-intr"
583 Causes
584 .I less
585 to exit immediately when an interrupt character (usually ^C) is typed.
586 Normally, an interrupt character causes
587 .I less
588 to stop whatever it is doing and return to its command prompt.
589 .IP "\-L or \-\-no-lessopen"
590 Ignore the LESSOPEN environment variable
591 (see the INPUT PREPROCESSOR section below).
592 This option can be set from within \fIless\fP, 
593 but it will apply only to files opened subsequently, not to the 
594 file which is currently open.
595 .IP "\-m or \-\-long-prompt"
596 Causes 
597 .I less
598 to prompt verbosely (like \fImore\fP),
599 with the percent into the file.
600 By default,
601 .I less
602 prompts with a colon.
603 .IP "\-M or \-\-LONG-PROMPT"
604 Causes 
605 .I less
606 to prompt even more verbosely than 
607 .I more.
608 .IP "\-n or \-\-line-numbers"
609 Suppresses line numbers.
610 The default (to use line numbers) may cause
611 .I less
612 to run more slowly in some cases, especially with a very large input file.
613 Suppressing line numbers with the \-n option will avoid this problem.
614 Using line numbers means: the line number will be displayed in the verbose
615 prompt and in the = command,
616 and the v command will pass the current line number to the editor
617 (see also the discussion of LESSEDIT in PROMPTS below).
618 .IP "\-N or \-\-LINE-NUMBERS"
619 Causes a line number to be displayed at the beginning of
620 each line in the display.
621 .IP "\-o\fIfilename\fP or \-\-log-file=\fIfilename\fP"
622 Causes
623 .I less
624 to copy its input to the named file as it is being viewed.
625 This applies only when the input file is a pipe,
626 not an ordinary file.
627 If the file already exists, 
628 .I less
629 will ask for confirmation before overwriting it.
630 .IP "\-O\fIfilename\fP or \-\-LOG-FILE=\fIfilename\fP"
631 The \-O option is like \-o, but it will overwrite an existing
632 file without asking for confirmation.
633 .sp
634 If no log file has been specified,
635 the \-o and \-O options can be used from within 
636 .I less
637 to specify a log file.
638 Without a file name, they will simply report the name of the log file.
639 The "s" command is equivalent to specifying \-o from within
640 .I less.
641 .IP "\-p\fIpattern\fP or \-\-pattern=\fIpattern\fP"
642 The \-p option on the command line is equivalent to 
643 specifying +/\fIpattern\fP;
644 that is, it tells
645 .I less
646 to start at the first occurrence of \fIpattern\fP in the file.
647 .IP "\-P\fIprompt\fP or \-\-prompt=\fIprompt\fP"
648 Provides a way to tailor the three prompt
649 styles to your own preference.
650 This option would normally be put in the LESS environment
651 variable, rather than being typed in with each 
652 .I less
653 command.
654 Such an option must either be the last option in the LESS variable,
655 or be terminated by a dollar sign.
656 -Ps followed by a string changes the default (short) prompt 
657 to that string.
658 -Pm changes the medium (\-m) prompt.
659 -PM changes the long (\-M) prompt.
660 -Ph changes the prompt for the help screen.
661 -P= changes the message printed by the = command.
662 -Pw changes the message printed while waiting for data (in the F command).
663 All prompt strings consist of a sequence of 
664 letters and special escape sequences.
665 See the section on PROMPTS for more details.
666 .IP "\-q or \-\-quiet or \-\-silent"
667 Causes moderately "quiet" operation:
668 the terminal bell is not rung 
669 if an attempt is made to scroll past the end of the file
670 or before the beginning of the file.
671 If the terminal has a "visual bell", it is used instead.
672 The bell will be rung on certain other errors,
673 such as typing an invalid character.
674 The default is to ring the terminal bell in all such cases.
675 .IP "\-Q or \-\-QUIET or \-\-SILENT"
676 Causes totally "quiet" operation:
677 the terminal bell is never rung.
678 .IP "\-r or \-\-raw-control-chars"
679 Causes "raw" control characters to be displayed.
680 The default is to display control characters using the caret notation;
681 for example, a control-A (octal 001) is displayed as "^A".
682 Warning: when the \-r option is used,
683 .I less
684 cannot keep track of the actual appearance of the screen
685 (since this depends on how the screen responds to
686 each type of control character).
687 Thus, various display problems may result,
688 such as long lines being split in the wrong place.
689 .IP "\-R or \-\-RAW-CONTROL-CHARS"
690 Like \-r, but only ANSI "color" escape sequences are output in "raw" form.
691 Unlike \-r, the screen appearance is maintained correctly in most cases.
692 ANSI "color" escape sequences are sequences of the form:
693 .sp
694         ESC [ ... m
695 .sp
696 where the "..." is zero or more color specification characters 
697 For the purpose of keeping track of screen appearance,
698 ANSI color escape sequences are assumed to not move the cursor.
699 You can make
700 .I less
701 think that characters other than "m" can end ANSI color escape sequences
702 by setting the environment variable LESSANSIENDCHARS to the list of
703 characters which can end a color escape sequence.
704 And you can make 
705 .I less 
706 think that characters other than the standard ones may appear between 
707 the ESC and the m by setting the environment variable LESSANSIMIDCHARS
708 to the list of characters which can appear.
709 .IP "\-s or \-\-squeeze-blank-lines"
710 Causes consecutive blank lines to be squeezed into a single blank line.
711 This is useful when viewing
712 .I nroff
713 output.
714 .IP "\-S or \-\-chop-long-lines"
715 Causes lines longer than the screen width to be
716 chopped rather than folded.
717 That is, the portion of a long line that does not fit in
718 the screen width is not shown.
719 The default is to fold long lines; that is, display the remainder
720 on the next line.
721 .IP "\-t\fItag\fP or \-\-tag=\fItag\fP"
722 The \-t option, followed immediately by a TAG,
723 will edit the file containing that tag.
724 For this to work, tag information must be available;
725 for example, there may be a file in the current directory called "tags",
726 which was previously built by 
727 .I ctags
728 (1) or an equivalent command.
729 If the environment variable LESSGLOBALTAGS is set, it is taken to be
730 the name of a command compatible with 
731 .I global
732 (1), and that command is executed to find the tag.
733 (See http://www.gnu.org/software/global/global.html).
734 The \-t option may also be specified from within 
735 .I less 
736 (using the \- command) as a way of examining a new file.
737 The command ":t" is equivalent to specifying \-t from within
738 .I less.
739 .IP "\-T\fItagsfile\fP or \-\-tag-file=\fItagsfile\fP"
740 Specifies a tags file to be used instead of "tags".
741 .IP "\-u or \-\-underline-special"
742 Causes backspaces and carriage returns to be treated as printable characters;
743 that is, they are sent to the terminal when they appear in the input.
744 .IP "\-U or \-\-UNDERLINE-SPECIAL"
745 Causes backspaces, tabs and carriage returns to be 
746 treated as control characters;
747 that is, they are handled as specified by the \-r option.
748 .sp
749 By default, if neither \-u nor \-U is given,
750 backspaces which appear adjacent to an underscore character
751 are treated specially:
752 the underlined text is displayed 
753 using the terminal's hardware underlining capability.
754 Also, backspaces which appear between two identical characters
755 are treated specially: 
756 the overstruck text is printed 
757 using the terminal's hardware boldface capability.
758 Other backspaces are deleted, along with the preceding character.
759 Carriage returns immediately followed by a newline are deleted.
760 other carriage returns are handled as specified by the \-r option.
761 Text which is overstruck or underlined can be searched for
762 if neither \-u nor \-U is in effect.
763 .IP "\-V or \-\-version"
764 Displays the version number of 
765 .I less.
766 .IP "\-w or \-\-hilite-unread"
767 Temporarily highlights the first "new" line after a forward movement
768 of a full page.
769 The first "new" line is the line immediately following the line previously
770 at the bottom of the screen.
771 Also highlights the target line after a g or p command.
772 The highlight is removed at the next command which causes movement.
773 The entire line is highlighted, unless the \-J option is in effect,
774 in which case only the status column is highlighted.
775 .IP "\-W or \-\-HILITE-UNREAD"
776 Like \-w, but temporarily highlights the first new line after any 
777 forward movement command larger than one line.
778 .IP "\-x\fIn\fP,... or \-\-tabs=\fIn\fP,..."
779 Sets tab stops.
780 If only one \fIn\fP is specified, tab stops are set at multiples of \fIn\fP.
781 If multiple values separated by commas are specified, tab stops
782 are set at those positions, and then continue with the same spacing as the
783 last two.
784 For example, \fI-x9,17\fP will set tabs at positions 9, 17, 25, 33, etc.
785 The default for \fIn\fP is 8.
786 .IP "\-X or \-\-no-init"
787 Disables sending the termcap initialization and deinitialization strings
788 to the terminal.
789 This is sometimes desirable if the deinitialization string does
790 something unnecessary, like clearing the screen.
791 .IP "\-\-no-keypad"
792 Disables sending the keypad initialization and deinitialization strings
793 to the terminal.
794 This is sometimes useful if the keypad strings make the numeric
795 keypad behave in an undesirable manner.
796 .IP "\-y\fIn\fP or \-\-max-forw-scroll=\fIn\fP"
797 Specifies a maximum number of lines to scroll forward.
798 If it is necessary to scroll forward more than \fIn\fP lines,
799 the screen is repainted instead.
800 The \-c or \-C option may be used to repaint from the top of
801 the screen if desired.
802 By default, any forward movement causes scrolling.
803 .IP "\-[z]\fIn\fP or \-\-window=\fIn\fP"
804 Changes the default scrolling window size to \fIn\fP lines.
805 The default is one screenful.
806 The z and w commands can also be used to change the window size.
807 The "z" may be omitted for compatibility with
808 .I more.
809 If the number
810 .I n
811 is negative, it indicates 
812 .I n
813 lines less than the current screen size.
814 For example, if the screen is 24 lines, \fI\-z-4\fP sets the 
815 scrolling window to 20 lines.  If the screen is resized to 40 lines,
816 the scrolling window automatically changes to 36 lines.
817 .IP "\-\fI\(dqcc\fP\ or\ \-\-quotes=\fIcc\fP"
818 Changes the filename quoting character.
819 This may be necessary if you are trying to name a file
820 which contains both spaces and quote characters.
821 Followed by a single character, this changes the quote character to that
822 character.
823 Filenames containing a space should then be surrounded by that character
824 rather than by double quotes.
825 Followed by two characters, changes the open quote to the first character,
826 and the close quote to the second character.
827 Filenames containing a space should then be preceded by the open quote
828 character and followed by the close quote character.
829 Note that even after the quote characters are changed, this option
830 remains \-" (a dash followed by a double quote).
831 .IP "\-~ or \-\-tilde"
832 Normally lines after end of file are displayed as a single tilde (~).
833 This option causes lines after end of file to be displayed as blank lines.
834 .IP "\-# or \-\-shift"
835 Specifies the default number of positions to scroll horizontally
836 in the RIGHTARROW and LEFTARROW commands.
837 If the number specified is zero, it sets the default number of
838 positions to one half of the screen width.
839 .IP \-\-
840 A command line argument of "\-\-" marks the end of option arguments.
841 Any arguments following this are interpreted as filenames.
842 This can be useful when viewing a file whose name begins with a "\-" or "+".
843 .IP +
844 If a command line option begins with \fB+\fP,
845 the remainder of that option is taken to be an initial command to
846 .I less.
847 For example, +G tells
848 .I less
849 to start at the end of the file rather than the beginning,
850 and +/xyz tells it to start at the first occurrence of "xyz" in the file.
851 As a special case, +<number> acts like +<number>g; 
852 that is, it starts the display at the specified line number
853 (however, see the caveat under the "g" command above).
854 If the option starts with ++, the initial command applies to
855 every file being viewed, not just the first one.
856 The + command described previously
857 may also be used to set (or change) an initial command for every file.
858
859 .SH "LINE EDITING"
860 When entering command line at the bottom of the screen
861 (for example, a filename for the :e command,
862 or the pattern for a search command),
863 certain keys can be used to manipulate the command line.
864 Most commands have an alternate form in [ brackets ] which can be used if
865 a key does not exist on a particular keyboard. 
866 (The bracketed forms do not work in the MS-DOS version.)
867 Any of these special keys may be entered literally by preceding
868 it with the "literal" character, either ^V or ^A.
869 A backslash itself may also be entered literally by entering two backslashes.
870 .IP "LEFTARROW [ ESC-h ]"
871 Move the cursor one space to the left.
872 .IP "RIGHTARROW [ ESC-l ]"
873 Move the cursor one space to the right.
874 .IP "^LEFTARROW [ ESC-b or ESC-LEFTARROW ]"
875 (That is, CONTROL and LEFTARROW simultaneously.)
876 Move the cursor one word to the left.
877 .IP "^RIGHTARROW [ ESC-w or ESC-RIGHTARROW ]"
878 (That is, CONTROL and RIGHTARROW simultaneously.)
879 Move the cursor one word to the right.
880 .IP "HOME [ ESC-0 ]"
881 Move the cursor to the beginning of the line.
882 .IP "END [ ESC-$ ]"
883 Move the cursor to the end of the line.
884 .IP "BACKSPACE"
885 Delete the character to the left of the cursor,
886 or cancel the command if the command line is empty.
887 .IP "DELETE or [ ESC-x ]"
888 Delete the character under the cursor.
889 .IP "^BACKSPACE [ ESC-BACKSPACE ]"
890 (That is, CONTROL and BACKSPACE simultaneously.)
891 Delete the word to the left of the cursor.
892 .IP "^DELETE [ ESC-X or ESC-DELETE ]"
893 (That is, CONTROL and DELETE simultaneously.)
894 Delete the word under the cursor.
895 .IP "UPARROW [ ESC-k ]"
896 Retrieve the previous command line.
897 .IP "DOWNARROW [ ESC-j ]"
898 Retrieve the next command line.
899 .IP "TAB"
900 Complete the partial filename to the left of the cursor.
901 If it matches more than one filename, the first match
902 is entered into the command line.
903 Repeated TABs will cycle thru the other matching filenames.
904 If the completed filename is a directory, a "/" is appended to the filename.
905 (On MS-DOS systems, a "\e" is appended.)
906 The environment variable LESSSEPARATOR can be used to specify a 
907 different character to append to a directory name.
908 .IP "BACKTAB [ ESC-TAB ]"
909 Like, TAB, but cycles in the reverse direction thru the matching filenames.
910 .IP "^L"
911 Complete the partial filename to the left of the cursor.
912 If it matches more than one filename, all matches are entered into
913 the command line (if they fit).
914 .IP "^U (Unix and OS/2) or ESC (MS-DOS)"
915 Delete the entire command line,
916 or cancel the command if the command line is empty.
917 If you have changed your line-kill character in Unix to something
918 other than ^U, that character is used instead of ^U.
919
920 .SH "KEY BINDINGS"
921 You may define your own 
922 .I less
923 commands by using the program 
924 .I lesskey
925 (1)
926 to create a lesskey file.
927 This file specifies a set of command keys and an action
928 associated with each key.
929 You may also use
930 .I lesskey
931 to change the line-editing keys (see LINE EDITING),
932 and to set environment variables.
933 If the environment variable LESSKEY is set,
934 .I less
935 uses that as the name of the lesskey file.
936 Otherwise, 
937 .I less
938 looks in a standard place for the lesskey file:
939 On Unix systems,
940 .I less
941 looks for a lesskey file called "$HOME/.less".
942 On MS-DOS and Windows systems,
943 .I less
944 looks for a lesskey file called "$HOME/_less", and if it is not found there,
945 then looks for a lesskey file called "_less" in any directory specified
946 in the PATH environment variable.
947 On OS/2 systems,
948 .I less
949 looks for a lesskey file called "$HOME/less.ini", and if it is not found,
950 then looks for a lesskey file called "less.ini" in any directory specified
951 in the INIT environment variable, and if it not found there,
952 then looks for a lesskey file called "less.ini" in any directory specified
953 in the PATH environment variable.
954 See the
955 .I lesskey
956 manual page for more details.
957 .P
958 A system-wide lesskey file may also be set up to provide key bindings.
959 If a key is defined in both a local lesskey file and in the
960 system-wide file, key bindings in the local file take precedence over 
961 those in the system-wide file.
962 If the environment variable LESSKEY_SYSTEM is set,
963 .I less
964 uses that as the name of the system-wide lesskey file.
965 Otherwise,
966 .I less 
967 looks in a standard place for the system-wide lesskey file:
968 On Unix systems, the system-wide lesskey file is /usr/local/etc/sysless.
969 (However, if 
970 .I less 
971 was built with a different sysconf directory than /usr/local/etc,
972 that directory is where the sysless file is found.)
973 On MS-DOS and Windows systems, the system-wide lesskey file is c:\e_sysless.
974 On OS/2 systems, the system-wide lesskey file is c:\esysless.ini.
975
976 .SH "INPUT PREPROCESSOR"
977 You may define an "input preprocessor" for 
978 .I less.
979 Before
980 .I less
981 opens a file, it first gives your input preprocessor a chance to modify the
982 way the contents of the file are displayed.
983 An input preprocessor is simply an executable program (or shell script),
984 which writes the contents of the file to a different file,
985 called the replacement file.
986 The contents of the replacement file are then displayed 
987 in place of the contents of the original file.
988 However, it will appear to the user as if the original file is opened;
989 that is, 
990 .I less
991 will display the original filename as the name of the current file.
992 .PP
993 An input preprocessor receives one command line argument, the original filename,
994 as entered by the user.
995 It should create the replacement file, and when finished,
996 print the name of the replacement file to its standard output.
997 If the input preprocessor does not output a replacement filename, 
998 .I less
999 uses the original file, as normal.
1000 The input preprocessor is not called when viewing standard input.
1001 To set up an input preprocessor, set the LESSOPEN environment variable
1002 to a command line which will invoke your input preprocessor.
1003 This command line should include one occurrence of the string "%s", 
1004 which will be replaced by the filename
1005 when the input preprocessor command is invoked.
1006 .PP
1007 When 
1008 .I less
1009 closes a file opened in such a way, it will call another program,
1010 called the input postprocessor,
1011 which may perform any desired clean-up action (such as deleting the
1012 replacement file created by LESSOPEN).
1013 This program receives two command line arguments, the original filename
1014 as entered by the user, and the name of the replacement file.
1015 To set up an input postprocessor, set the LESSCLOSE environment variable 
1016 to a command line which will invoke your input postprocessor.
1017 It may include two occurrences of the string "%s"; 
1018 the first is replaced with the original name of the file and 
1019 the second with the name of the replacement file, 
1020 which was output by LESSOPEN.
1021 .PP
1022 For example, on many Unix systems, these two scripts will allow you
1023 to keep files in compressed format, but still let
1024 .I less
1025 view them directly:
1026 .PP
1027 lessopen.sh:
1028 .br
1029         #! /bin/sh
1030 .br
1031         case "$1" in
1032 .br
1033         *.Z)    uncompress -\c $1  >/tmp/less.$$  2>/dev/null
1034 .br
1035                 if [ \-s /tmp/less.$$ ]; then 
1036 .br
1037                         echo /tmp/less.$$
1038 .br
1039                 else
1040 .br
1041                         rm \-f /tmp/less.$$
1042 .br
1043                 fi
1044 .br
1045                 ;;
1046 .br
1047         esac
1048 .PP
1049 lessclose.sh:
1050 .br
1051         #! /bin/sh
1052 .br
1053         rm $2
1054 .PP
1055 To use these scripts, put them both where they can be executed and
1056 set LESSOPEN="lessopen.sh\ %s", and
1057 LESSCLOSE="lessclose.sh\ %s\ %s".
1058 More complex LESSOPEN and LESSCLOSE scripts may be written
1059 to accept other types of compressed files, and so on.
1060 .PP
1061 It is also possible to set up an input preprocessor to
1062 pipe the file data directly to 
1063 .I less,
1064 rather than putting the data into a replacement file.
1065 This avoids the need to decompress the entire file before 
1066 starting to view it.
1067 An input preprocessor that works this way is called an input pipe.
1068 An input pipe, instead of writing the name of a replacement file on
1069 its standard output,
1070 writes the entire contents of the replacement file on its standard output.
1071 If the input pipe does not write any characters on its standard output,
1072 then there is no replacement file and 
1073 .I less
1074 uses the original file, as normal.
1075 To use an input pipe,
1076 make the first character in the LESSOPEN environment variable a 
1077 vertical bar (|) to signify that the input preprocessor is an input pipe.
1078 .PP
1079 For example, on many Unix systems, this script will work like the
1080 previous example scripts:
1081 .PP
1082 lesspipe.sh:
1083 .br
1084         #! /bin/sh
1085 .br
1086         case "$1" in
1087 .br
1088         *.Z)    uncompress \-c $1  2>/dev/null
1089 .br
1090                 ;;
1091 .br
1092         esac
1093 .br
1094 .PP
1095 To use this script, put it where it can be executed and set
1096 LESSOPEN="|lesspipe.sh %s".
1097 When an input pipe is used, a LESSCLOSE postprocessor can be used,
1098 but it is usually not necessary since there is no replacement file
1099 to clean up.
1100 In this case, the replacement file name passed to the LESSCLOSE
1101 postprocessor is "\-".
1102
1103 .SH "NATIONAL CHARACTER SETS"
1104 There are three types of characters in the input file:
1105 .IP "normal characters"
1106 can be displayed directly to the screen.
1107 .IP "control characters"
1108 should not be displayed directly, but are expected to be found
1109 in ordinary text files (such as backspace and tab).
1110 .IP "binary characters"
1111 should not be displayed directly and are not expected to be found
1112 in text files.
1113 .PP
1114 A "character set" is simply a description of which characters are to
1115 be considered normal, control, and binary.
1116 The LESSCHARSET environment variable may be used to select a character set.
1117 Possible values for LESSCHARSET are:
1118 .IP ascii
1119 BS, TAB, NL, CR, and formfeed are control characters,
1120 all chars with values between 32 and 126 are normal,
1121 and all others are binary.
1122 .IP iso8859
1123 Selects an ISO 8859 character set.
1124 This is the same as ASCII, except characters between 160 and 255 are
1125 treated as normal characters.
1126 .IP latin1
1127 Same as iso8859.
1128 .IP latin9
1129 Same as iso8859.
1130 .IP dos
1131 Selects a character set appropriate for MS-DOS.
1132 .IP ebcdic
1133 Selects an EBCDIC character set.
1134 .IP IBM-1047
1135 Selects an EBCDIC character set used by OS/390 Unix Services.
1136 This is the EBCDIC analogue of latin1.  You get similar results
1137 by setting either LESSCHARSET=IBM-1047 or LC_CTYPE=en_US
1138 in your environment.
1139 .IP koi8-r
1140 Selects a Russian character set.
1141 .IP next
1142 Selects a character set appropriate for NeXT computers.
1143 .IP utf-8
1144 Selects the UTF-8 encoding of the ISO 10646 character set.
1145 .IP windows
1146 Selects a character set appropriate for Microsoft Windows (cp 1251).
1147 .PP
1148 In special cases, it may be desired to tailor
1149 .I less
1150 to use a character set other than the ones definable by LESSCHARSET.
1151 In this case, the environment variable LESSCHARDEF can be used
1152 to define a character set.
1153 It should be set to a string where each character in the string represents
1154 one character in the character set.
1155 The character "." is used for a normal character, "c" for control,
1156 and "b" for binary.
1157 A decimal number may be used for repetition.
1158 For example, "bccc4b." would mean character 0 is binary,
1159 1, 2 and 3 are control, 4, 5, 6 and 7 are binary, and 8 is normal.
1160 All characters after the last are taken to be the same as the last,
1161 so characters 9 through 255 would be normal.
1162 (This is an example, and does not necessarily 
1163 represent any real character set.)
1164 .PP
1165 This table shows the value of LESSCHARDEF which is equivalent
1166 to each of the possible values for LESSCHARSET:
1167 .sp
1168         ascii\  8bcccbcc18b95.b
1169 .br
1170         dos\ \ \        8bcccbcc12bc5b95.b.
1171 .br
1172         ebcdic  5bc6bcc7bcc41b.9b7.9b5.b..8b6.10b6.b9.7b
1173 .br
1174         \ \ \ \ \ \     9.8b8.17b3.3b9.7b9.8b8.6b10.b.b.b.
1175 .br
1176         IBM-1047        4cbcbc3b9cbccbccbb4c6bcc5b3cbbc4bc4bccbc
1177 .br
1178         \ \ \ \ \ \     191.b
1179 .br
1180         iso8859 8bcccbcc18b95.33b.
1181 .br
1182         koi8-r  8bcccbcc18b95.b128.
1183 .br
1184         latin1  8bcccbcc18b95.33b.
1185 .br
1186         next\ \         8bcccbcc18b95.bb125.bb
1187 .PP
1188 If neither LESSCHARSET nor LESSCHARDEF is set,
1189 but any of the strings "UTF-8", "UTF8", "utf-8" or "utf8" 
1190 is found in the LC_ALL, LC_TYPE or LANG
1191 environment variables, then the default character set is utf-8.
1192 .PP
1193 If that string is not found, but your system supports the
1194 .I setlocale
1195 interface,
1196 .I less
1197 will use setlocale to determine the character set.
1198 setlocale is controlled by setting the LANG or LC_CTYPE environment
1199 variables.
1200 .PP
1201 Finally, if the
1202 .I setlocale
1203 interface is also not available, the default character set is latin1.
1204 .PP
1205 Control and binary characters are displayed in standout (reverse video).
1206 Each such character is displayed in caret notation if possible
1207 (e.g. ^A for control-A).  Caret notation is used only if 
1208 inverting the 0100 bit results in a normal printable character.
1209 Otherwise, the character is displayed as a hex number in angle brackets.
1210 This format can be changed by 
1211 setting the LESSBINFMT environment variable.
1212 LESSBINFMT may begin with a "*" and one character to select 
1213 the display attribute:
1214 "*k" is blinking, "*d" is bold, "*u" is underlined, "*s" is standout,
1215 and "*n" is normal.
1216 If LESSBINFMT does not begin with a "*", normal attribute is assumed.
1217 The remainder of LESSBINFMT is a string which may include one
1218 printf-style escape sequence (a % followed by x, X, o, d, etc.).
1219 For example, if LESSBINFMT is "*u[%x]", binary characters
1220 are displayed in underlined hexadecimal surrounded by brackets.
1221 The default if no LESSBINFMT is specified is "*s<%X>".
1222 The default if no LESSBINFMT is specified is "*s<%02X>".
1223 Warning: the result of expanding the character via LESSBINFMT must
1224 be less than 31 characters.
1225 .PP
1226 When the character set is utf-8, the LESSUTFBINFMT environment variable
1227 acts similarly to LESSBINFMT but it applies to Unicode code points
1228 that were successfully decoded but are unsuitable for display (e.g.,
1229 unassigned code points).
1230 Its default value is "<U+%04lX>".
1231 Note that LESSUTFBINFMT and LESSBINFMT share their display attribute 
1232 setting ("*x") so specifying one will affect both; 
1233 LESSUTFBINFMT is read after LESSBINFMT so its setting, if any,
1234 will have priority. 
1235 Problematic octets in a UTF-8 file (octets of a truncated sequence,
1236 octets of a complete but non-shortest form sequence, illegal octets, 
1237 and stray trailing octets)
1238 are displayed individually using LESSBINFMT so as to facilitate diagnostic
1239 of how the UTF-8 file is ill-formed.
1240
1241 .SH "PROMPTS"
1242 The \-P option allows you to tailor the prompt to your preference.
1243 The string given to the \-P option replaces the specified prompt string.
1244 Certain characters in the string are interpreted specially.
1245 The prompt mechanism is rather complicated to provide flexibility,
1246 but the ordinary user need not understand the details of constructing
1247 personalized prompt strings.
1248 .sp
1249 A percent sign followed by a single character is expanded
1250 according to what the following character is:
1251 .IP "%b\fIX\fP"
1252 Replaced by the byte offset into the current input file.
1253 The b is followed by a single character (shown as \fIX\fP above)
1254 which specifies the line whose byte offset is to be used.
1255 If the character is a "t", the byte offset of the top line in the
1256 display is used,
1257 an "m" means use the middle line,
1258 a "b" means use the bottom line,
1259 a "B" means use the line just after the bottom line,
1260 and a "j" means use the "target" line, as specified by the \-j option.
1261 .IP "%B"
1262 Replaced by the size of the current input file.
1263 .IP "%c"
1264 Replaced by the column number of the text appearing in the first
1265 column of the screen.
1266 .IP "%d\fIX\fP"
1267 Replaced by the page number of a line in the input file.
1268 The line to be used is determined by the \fIX\fP, as with the %b option.
1269 .IP "%D"
1270 Replaced by the number of pages in the input file,
1271 or equivalently, the page number of the last line in the input file.
1272 .IP "%E"
1273 Replaced by the name of the editor (from the VISUAL environment variable,
1274 or the EDITOR environment variable if VISUAL is not defined).
1275 See the discussion of the LESSEDIT feature below.
1276 .IP "%f"
1277 Replaced by the name of the current input file.
1278 .IP "%i"
1279 Replaced by the index of the current file in the list of
1280 input files.
1281 .IP "%l\fIX\fP"
1282 Replaced by the line number of a line in the input file.
1283 The line to be used is determined by the \fIX\fP, as with the %b option.
1284 .IP "%L"
1285 Replaced by the line number of the last line in the input file.
1286 .IP "%m"
1287 Replaced by the total number of input files.
1288 .IP "%p\fIX\fP"
1289 Replaced by the percent into the current input file, based on byte offsets.
1290 The line used is determined by the \fIX\fP as with the %b option.
1291 .IP "%P\fIX\fP"
1292 Replaced by the percent into the current input file, based on line numbers.
1293 The line used is determined by the \fIX\fP as with the %b option.
1294 .IP "%s"
1295 Same as %B.
1296 .IP "%t"
1297 Causes any trailing spaces to be removed.
1298 Usually used at the end of the string, but may appear anywhere.
1299 .IP "%x"
1300 Replaced by the name of the next input file in the list.
1301 .PP
1302 If any item is unknown (for example, the file size if input
1303 is a pipe), a question mark is printed instead.
1304 .PP
1305 The format of the prompt string can be changed
1306 depending on certain conditions.
1307 A question mark followed by a single character acts like an "IF":
1308 depending on the following character, a condition is evaluated.
1309 If the condition is true, any characters following the question mark
1310 and condition character, up to a period, are included in the prompt.
1311 If the condition is false, such characters are not included.
1312 A colon appearing between the question mark and the
1313 period can be used to establish an "ELSE": any characters between
1314 the colon and the period are included in the string if and only if
1315 the IF condition is false.
1316 Condition characters (which follow a question mark) may be:
1317 .IP "?a"
1318 True if any characters have been included in the prompt so far.
1319 .IP "?b\fIX\fP"
1320 True if the byte offset of the specified line is known.
1321 .IP "?B"
1322 True if the size of current input file is known.
1323 .IP "?c"
1324 True if the text is horizontally shifted (%c is not zero).
1325 .IP "?d\fIX\fP"
1326 True if the page number of the specified line is known.
1327 .IP "?e"
1328 True if at end-of-file.
1329 .IP "?f"
1330 True if there is an input filename
1331 (that is, if input is not a pipe).
1332 .IP "?l\fIX\fP"
1333 True if the line number of the specified line is known.
1334 .IP "?L"
1335 True if the line number of the last line in the file is known.
1336 .IP "?m"
1337 True if there is more than one input file.
1338 .IP "?n"
1339 True if this is the first prompt in a new input file.
1340 .IP "?p\fIX\fP"
1341 True if the percent into the current input file, based on byte offsets,
1342 of the specified line is known.
1343 .IP "?P\fIX\fP"
1344 True if the percent into the current input file, based on line numbers,
1345 of the specified line is known.
1346 .IP "?s"
1347 Same as "?B".
1348 .IP "?x"
1349 True if there is a next input file
1350 (that is, if the current input file is not the last one).
1351 .PP
1352 Any characters other than the special ones
1353 (question mark, colon, period, percent, and backslash)
1354 become literally part of the prompt.
1355 Any of the special characters may be included in the prompt literally
1356 by preceding it with a backslash.
1357 .PP
1358 Some examples:
1359 .sp
1360 ?f%f:Standard input.
1361 .sp
1362 This prompt prints the filename, if known;
1363 otherwise the string "Standard input".
1364 .sp
1365 ?f%f .?ltLine %lt:?pt%pt\e%:?btByte %bt:-...
1366 .sp
1367 This prompt would print the filename, if known.
1368 The filename is followed by the line number, if known,
1369 otherwise the percent if known, otherwise the byte offset if known.
1370 Otherwise, a dash is printed.
1371 Notice how each question mark has a matching period,
1372 and how the % after the %pt
1373 is included literally by escaping it with a backslash.
1374 .sp
1375 ?n?f%f\ .?m(file\ %i\ of\ %m)\ ..?e(END)\ ?x-\ Next\e:\ %x..%t
1376 .sp
1377 This prints the filename if this is the first prompt in a file,
1378 followed by the "file N of N" message if there is more
1379 than one input file.
1380 Then, if we are at end-of-file, the string "(END)" is printed
1381 followed by the name of the next file, if there is one.
1382 Finally, any trailing spaces are truncated.
1383 This is the default prompt.
1384 For reference, here are the defaults for
1385 the other two prompts (\-m and \-M respectively).
1386 Each is broken into two lines here for readability only.
1387 .nf
1388 .sp
1389 ?n?f%f\ .?m(file\ %i\ of\ %m)\ ..?e(END)\ ?x-\ Next\e:\ %x.:
1390         ?pB%pB\e%:byte\ %bB?s/%s...%t
1391 .sp
1392 ?f%f\ .?n?m(file\ %i\ of\ %m)\ ..?ltlines\ %lt-%lb?L/%L.\ :
1393         byte\ %bB?s/%s.\ .?e(END)\ ?x-\ Next\e:\ %x.:?pB%pB\e%..%t
1394 .sp
1395 .fi
1396 And here is the default message produced by the = command:
1397 .nf
1398 .sp
1399 ?f%f\ .?m(file\ %i\ of\ %m)\ .?ltlines\ %lt-%lb?L/%L.\ .
1400         byte\ %bB?s/%s.\ ?e(END)\ :?pB%pB\e%..%t
1401 .fi
1402 .PP
1403 The prompt expansion features are also used for another purpose:
1404 if an environment variable LESSEDIT is defined, it is used
1405 as the command to be executed when the v command is invoked.
1406 The LESSEDIT string is expanded in the same way as the prompt strings.
1407 The default value for LESSEDIT is:
1408 .nf
1409 .sp
1410         %E\ ?lm+%lm.\ %f
1411 .sp
1412 .fi
1413 Note that this expands to the editor name, followed by a + and the
1414 line number, followed by the file name.
1415 If your editor does not accept the "+linenumber" syntax, or has other
1416 differences in invocation syntax, the LESSEDIT variable can be 
1417 changed to modify this default.
1418
1419 .SH SECURITY
1420 When the environment variable LESSSECURE is set to 1,
1421 .I less
1422 runs in a "secure" mode.
1423 This means these features are disabled:
1424 .RS
1425 .IP "!"
1426 the shell command
1427 .IP "|"
1428 the pipe command
1429 .IP ":e"
1430 the examine command.
1431 .IP "v"
1432 the editing command
1433 .IP "s  \-o"
1434 log files
1435 .IP "\-k"
1436 use of lesskey files
1437 .IP "\-t"
1438 use of tags files
1439 .IP " "
1440 metacharacters in filenames, such as *
1441 .IP " "
1442 filename completion (TAB, ^L)
1443 .RE
1444 .PP
1445 Less can also be compiled to be permanently in "secure" mode.
1446
1447 .SH "ENVIRONMENT VARIABLES"
1448 Environment variables may be specified either in the system environment
1449 as usual, or in a 
1450 .I lesskey
1451 (1) file.
1452 If environment variables are defined in more than one place, 
1453 variables defined in a local lesskey file take precedence over
1454 variables defined in the system environment, which take precedence
1455 over variables defined in the system-wide lesskey file.
1456 .IP COLUMNS
1457 Sets the number of columns on the screen.
1458 Takes precedence over the number of columns specified by the TERM variable.
1459 (But if you have a windowing system which supports TIOCGWINSZ or WIOCGETD,
1460 the window system's idea of the screen size takes precedence over the
1461 LINES and COLUMNS environment variables.)
1462 .IP EDITOR
1463 The name of the editor (used for the v command).
1464 .IP HOME
1465 Name of the user's home directory
1466 (used to find a lesskey file on Unix and OS/2 systems).
1467 .IP "HOMEDRIVE, HOMEPATH"
1468 Concatenation of the HOMEDRIVE and HOMEPATH environment variables is
1469 the name of the user's home directory if the HOME variable is not set
1470 (only in the Windows version).
1471 .IP INIT
1472 Name of the user's init directory (used to find a lesskey file on OS/2 systems).
1473 .IP LANG
1474 Language for determining the character set.
1475 .IP LC_CTYPE
1476 Language for determining the character set.
1477 .IP LESS
1478 Options which are passed to 
1479 .I less
1480 automatically.
1481 .IP LESSANSIENDCHARS
1482 Characters which may end an ANSI color escape sequence
1483 (default "m").
1484 .IP LESSANSIMIDCHARS
1485 Characters which may appear between the ESC character and the
1486 end character in an ANSI color escape sequence
1487 (default "0123456789;[?!"'#%()*+\ ".
1488 .IP LESSBINFMT
1489 Format for displaying non-printable, non-control characters.
1490 .IP LESSCHARDEF
1491 Defines a character set.
1492 .IP LESSCHARSET
1493 Selects a predefined character set.
1494 .IP LESSCLOSE
1495 Command line to invoke the (optional) input-postprocessor.
1496 .IP LESSECHO
1497 Name of the lessecho program (default "lessecho").
1498 The lessecho program is needed to expand metacharacters, such as * and ?,
1499 in filenames on Unix systems.
1500 .IP LESSEDIT
1501 Editor prototype string (used for the v command).
1502 See discussion under PROMPTS.
1503 .IP LESSGLOBALTAGS
1504 Name of the command used by the \-t option to find global tags.
1505 Normally should be set to "global" if your system has the
1506 .I global
1507 (1) command.  If not set, global tags are not used.
1508 .IP LESSHISTFILE
1509 Name of the history file used to remember search commands and
1510 shell commands between invocations of 
1511 .I less.
1512 If set to "\-", a history file is not used.
1513 The default is "$HOME/.lesshst" on Unix systems, "$HOME/_lesshst" on
1514 DOS and Windows systems, or "$HOME/lesshst.ini" or "$INIT/lesshst.ini" 
1515 on OS/2 systems.
1516 .IP LESSHISTSIZE
1517 The maximum number of commands to save in the history file.
1518 The default is 100.
1519 .IP LESSKEY
1520 Name of the default lesskey(1) file.
1521 .IP LESSKEY_SYSTEM
1522 Name of the default system-wide lesskey(1) file.
1523 .IP LESSMETACHARS
1524 List of characters which are considered "metacharacters" by the shell.
1525 .IP LESSMETAESCAPE
1526 Prefix which less will add before each metacharacter in a
1527 command sent to the shell.
1528 If LESSMETAESCAPE is an empty string, commands containing
1529 metacharacters will not be passed to the shell.
1530 .IP LESSOPEN
1531 Command line to invoke the (optional) input-preprocessor.
1532 .IP LESSSECURE
1533 Runs less in "secure" mode.
1534 See discussion under SECURITY.
1535 .IP LESSSEPARATOR
1536 String to be appended to a directory name in filename completion.
1537 .IP LESSUTFBINFMT
1538 Format for displaying non-printable Unicode code points.
1539 .IP LINES
1540 Sets the number of lines on the screen.
1541 Takes precedence over the number of lines specified by the TERM variable.
1542 (But if you have a windowing system which supports TIOCGWINSZ or WIOCGETD,
1543 the window system's idea of the screen size takes precedence over the
1544 LINES and COLUMNS environment variables.)
1545 .IP PATH
1546 User's search path (used to find a lesskey file 
1547 on MS-DOS and OS/2 systems).
1548 .IP SHELL
1549 The shell used to execute the ! command, as well as to expand filenames.
1550 .IP TERM
1551 The type of terminal on which
1552 .I less
1553 is being run.
1554 .IP VISUAL
1555 The name of the editor (used for the v command).
1556
1557 .SH "SEE ALSO"
1558 lesskey(1)
1559
1560 .SH WARNINGS
1561 The = command and prompts (unless changed by \-P)
1562 report the line numbers of the lines at the top and bottom of the screen,
1563 but the byte and percent of the line after the one at the bottom of the screen.
1564 .PP
1565 If the :e command is used to name more than one file,
1566 and one of the named files has been viewed previously,
1567 the new files may be entered into the list in an unexpected order.
1568 .PP
1569 On certain older terminals (the so-called "magic cookie" terminals),
1570 search highlighting will cause an erroneous display.
1571 On such terminals, search highlighting is disabled by default 
1572 to avoid possible problems.
1573 .PP
1574 In certain cases, when search highlighting is enabled and 
1575 a search pattern begins with a ^,
1576 more text than the matching string may be highlighted.
1577 (This problem does not occur when less is compiled to use the POSIX
1578 regular expression package.)
1579 .PP
1580 When viewing text containing ANSI color escape sequences using the \-R option,
1581 searching will not find text containing an embedded escape sequence.
1582 Also, search highlighting may change the color of some of the text
1583 which follows the highlighted text.
1584 .PP
1585 On some systems,
1586 .I setlocale
1587 claims that ASCII characters 0 thru 31 are control characters 
1588 rather than binary characters.
1589 This causes 
1590 .I less 
1591 to treat some binary files as ordinary, non-binary files.
1592 To workaround this problem, set the environment variable
1593 LESSCHARSET to "ascii" (or whatever character set is appropriate).
1594 .PP
1595 This manual is too long.
1596 .PP
1597 See http://www.greenwoodsoftware.com/less for the list of known bugs in all versions of less.
1598
1599 .SH COPYRIGHT
1600 Copyright (C) 1984-2005  Mark Nudelman
1601 .PP
1602 less is part of the GNU project and is free software.
1603 You can redistribute it and/or modify it
1604 under the terms of either
1605 (1) the GNU General Public License as published by
1606 the Free Software Foundation; or (2) the Less License.
1607 See the file README in the less distribution for more details
1608 regarding redistribution.
1609 You should have received a copy of the GNU General Public License 
1610 along with the source for less; see the file COPYING.
1611 If not, write to the Free Software Foundation, 59 Temple Place,
1612 Suite 330, Boston, MA  02111-1307, USA.
1613 You should also have received a copy of the Less License;
1614 see the file LICENSE.
1615 .PP
1616 less is distributed in the hope that it will be useful, but
1617 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
1618 or FITNESS FOR A PARTICULAR PURPOSE.
1619 See the GNU General Public License for more details.
1620
1621 .SH AUTHOR
1622 .PP
1623 Mark Nudelman <markn@greenwoodsoftware.com>
1624 .br
1625 Send bug reports or comments to the above address or to bug-less@gnu.org.
1626 .br
1627 For more information, see the less homepage at http://www.greenwoodsoftware.com/less.