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