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