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