comparison miscellany/less-177/less.man @ 0:bce86c4163a3

Initial revision
author kono
date Mon, 18 Apr 2005 23:46:02 +0900
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:bce86c4163a3
1
2
3
4 LESS(1) LESS(1)
5
6
7 NNAAMMEE
8 less - opposite of more
9
10 SSYYNNOOPPSSIISS
11 lleessss --??
12 lleessss [[--[[++]]aaBBccCCddeeEEffHHiimmMMnnNNqqQQrrssSSuuUUww]]
13 [[--bb _b_u_f_s]] [[--hh _l_i_n_e_s]] [[--jj _l_i_n_e]] [[--kk _k_e_y_f_i_l_e]]
14 [[--{{ooOO}} _l_o_g_f_i_l_e]] [[--pp _p_a_t_t_e_r_n]] [[--PP _p_r_o_m_p_t]] [[--tt _t_a_g]]
15 [[--TT _t_a_g_f_i_l_e]] [[--xx _t_a_b]] [[--yy _l_i_n_e_s]] [[--[[zz]] _l_i_n_e_s]]
16 [[++[[++]]_c_m_d]] [[_f_i_l_e_n_a_m_e]]......
17
18
19 DDEESSCCRRIIPPTTIIOONN
20 _L_e_s_s is a program similar to _m_o_r_e (1), but which allows
21 backward movement in the file as well as forward movement.
22 Also, _l_e_s_s does not have to read the entire input file
23 before starting, so with large input files it starts up
24 faster than text editors like _v_i (1). _L_e_s_s uses termcap
25 (or terminfo on some systems), so it can run on a variety
26 of terminals. There is even limited support for hardcopy
27 terminals. (On a hardcopy terminal, lines which should be
28 printed at the top of the screen are prefixed with an up-
29 arrow.)
30
31 Commands are based on both _m_o_r_e and _v_i_. Commands may be
32 preceded by a decimal number, called N in the descriptions
33 below. The number is used by some commands, as indicated.
34
35
36 CCOOMMMMAANNDDSS
37 In the following descriptions, ^X means control-X. ESC
38 stands for the ESCAPE key; for example ESC-v means the two
39 character sequence "ESCAPE", then "v".
40
41 h or H Help: display a summary of these commands. If you
42 forget all the other commands, remember this one.
43
44
45 SPACE or ^V or f or ^F
46 Scroll forward N lines, default one window (see
47 option -z below). If N is more than the screen
48 size, only the final screenful is displayed. Warn-
49 ing: some systems use ^V as a special literaliza-
50 tion character.
51
52
53 z Like SPACE, but if N is specified, it becomes the
54 new window size.
55
56
57 RETURN or ^N or e or ^E or j or ^J
58 Scroll forward N lines, default 1. The entire N
59 lines are displayed, even if N is more than the
60 screen size.
61
62
63
64 1
65
66
67
68
69
70 LESS(1) LESS(1)
71
72
73 d or ^D
74 Scroll forward N lines, default one half of the
75 screen size. If N is specified, it becomes the new
76 default for subsequent d and u commands.
77
78
79 b or ^B or ESC-v
80 Scroll backward N lines, default one window (see
81 option -z below). If N is more than the screen
82 size, only the final screenful is displayed.
83
84
85 w Like ESC-v, but if N is specified, it becomes the
86 new window size.
87
88
89 y or ^Y or ^P or k or ^K
90 Scroll backward N lines, default 1. The entire N
91 lines are displayed, even if N is more than the
92 screen size. Warning: some systems use ^Y as a
93 special job control character.
94
95
96 u or ^U
97 Scroll backward N lines, default one half of the
98 screen size. If N is specified, it becomes the new
99 default for subsequent d and u commands.
100
101
102 r or ^R or ^L
103 Repaint the screen.
104
105
106 R Repaint the screen, discarding any buffered input.
107 Useful if the file is changing while it is being
108 viewed.
109
110
111 F Scroll forward, and keep trying to read when the
112 end of file is reached. Normally this command
113 would be used when already at the end of the file.
114 It is a way to monitor the tail of a file which is
115 growing while it is being viewed. (The behavior is
116 similar to the "tail -f" command.)
117
118
119 g or < or ESC-<
120 Go to line N in the file, default 1 (beginning of
121 file). (Warning: this may be slow if N is large.)
122
123
124 G or > or ESC->
125 Go to line N in the file, default the end of the
126 file. (Warning: this may be slow if N is large, or
127
128
129
130 2
131
132
133
134
135
136 LESS(1) LESS(1)
137
138
139 if N is not specified and standard input, rather
140 than a file, is being read.)
141
142
143 p or % Go to a position N percent into the file. N should
144 be between 0 and 100. (This works if standard
145 input is being read, but only if _l_e_s_s has already
146 read to the end of the file. It is always fast,
147 but not always useful.)
148
149
150 { If a left curly bracket appears in the top line
151 displayed on the screen, the { command will go to
152 the matching right curly bracket. The matching
153 right curly bracket is positioned on the bottom
154 line of the screen. If there is more than one left
155 curly bracket on the top line, a number N may be
156 used to specify the N-th bracket on the line.
157
158
159 } If a right curly bracket appears in the bottom line
160 displayed on the screen, the } command will go to
161 the matching left curly bracket. The matching left
162 curly bracket is positioned on the top line of the
163 screen. If there is more than one right curly
164 bracket on the top line, a number N may be used to
165 specify the N-th bracket on the line.
166
167
168 ( Like {, but applies to parentheses rather than
169 curly brackets.
170
171
172 ) Like }, but applies to parentheses rather than
173 curly brackets.
174
175
176 [ Like {, but applies to square brackets rather than
177 curly brackets.
178
179
180 ] Like }, but applies to square brackets rather than
181 curly brackets.
182
183
184 ESC-^F Followed by two characters, acts like {, but uses
185 the two characters as open and close brackets,
186 respectively. For example, "ESC ^F < >" could be
187 used to go forward to the > which matches the < in
188 the top displayed line.
189
190 ESC-^B Followed by two characters, acts like }, but uses
191 the two characters as open and close brackets,
192 respectively. For example, "ESC ^B < >" could be
193
194
195
196 3
197
198
199
200
201
202 LESS(1) LESS(1)
203
204
205 used to go backward to the < which matches the > in
206 the bottom displayed line.
207
208 m Followed by any lowercase letter, marks the current
209 position with that letter.
210
211
212 ' (Single quote.) Followed by any lowercase letter,
213 returns to the position which was previously marked
214 with that letter. Followed by another single
215 quote, returns to the position at which the last
216 "large" movement command was executed. Followed by
217 a ^ or $, jumps to the beginning or end of the file
218 respectively. Marks are preserved when a new file
219 is examined, so the ' command can be used to switch
220 between input files.
221
222
223 ^X^X Same as single quote.
224
225
226 /pattern
227 Search forward in the file for the N-th line con-
228 taining the pattern. N defaults to 1. The pattern
229 is a regular expression, as recognized by _e_d_. The
230 search starts at the second line displayed (but see
231 the -a and -j options, which change this).
232
233 Certain characters are special if entered at the
234 beginning of the pattern; they modify the type of
235 search rather than become part of the pattern:
236
237 ! Search for lines which do NOT match the pat-
238 tern.
239
240 * Search multiple files. That is, if the
241 search reaches the end of the current file
242 without finding a match, the search contin-
243 ues in the next file in the command line
244 list.
245
246 @ Begin the search at the first line of the
247 first file in the command line list, regard-
248 less of what is currently displayed on the
249 screen or the settings of the -a or -j
250 options.
251
252
253 ?pattern
254 Search backward in the file for the N-th line con-
255 taining the pattern. The search starts at the line
256 immediately before the top line displayed.
257
258 Certain characters are special as in the / command:
259
260
261
262 4
263
264
265
266
267
268 LESS(1) LESS(1)
269
270
271 ! Search for lines which do NOT match the pat-
272 tern.
273
274 * Search multiple files. That is, if the
275 search reaches the beginning of the current
276 file without finding a match, the search
277 continues in the previous file in the com-
278 mand line list.
279
280 @ Begin the search at the last line of the
281 last file in the command line list, regard-
282 less of what is currently displayed on the
283 screen or the settings of the -a or -j
284 options.
285
286
287 ESC-/pattern
288 Same as "/*".
289
290
291 ESC-?pattern
292 Same as "?*".
293
294
295 n Repeat previous search, for N-th line containing
296 the last pattern. If the previous search was modi-
297 fied by !, the search is made for the N-th line NOT
298 containing the pattern. If the previous search was
299 modified by *, the search continues in the next (or
300 previous) file if not satisfied in the current
301 file. There is no effect if the previous search
302 was modified by @.
303
304
305 N Repeat previous search, but in the reverse direc-
306 tion.
307
308
309 ESC-n Repeat previous search, but crossing file bound-
310 aries. The effect is as if the previous search
311 were modified by *.
312
313
314 ESC-N Repeat previous search, but in the reverse direc-
315 tion and crossing file boundaries.
316
317
318 :e [filename]
319 Examine a new file. If the filename is missing,
320 the "current" file (see the :n and :p commands
321 below) from the list of files in the command line
322 is re-examined. A percent sign (%) in the filename
323 is replaced by the name of the current file. A
324 pound sign (#) is replaced by the name of the
325
326
327
328 5
329
330
331
332
333
334 LESS(1) LESS(1)
335
336
337 previously examined file. The filename is inserted
338 into the command line list of files so that it can
339 be seen by subsequent :n and :p commands. If the
340 filename consists of several files, they are all
341 inserted into the list of files and the first one
342 is examined.
343
344
345 ^X^V or E
346 Same as :e. Warning: some systems use ^V as a spe-
347 cial literalization character.
348
349
350 :n Examine the next file (from the list of files given
351 in the command line). If a number N is specified,
352 the N-th next file is examined.
353
354
355 :p Examine the previous file in the command line list.
356 If a number N is specified, the N-th previous file
357 is examined.
358
359
360 :x Examine the first file in the command line list.
361 If a number N is specified, the N-th file in the
362 list is examined.
363
364
365 = or ^G or :f
366 Prints some information about the file being
367 viewed, including its name and the line number and
368 byte offset of the bottom line being displayed. If
369 possible, it also prints the length of the file,
370 the number of lines in the file and the percent of
371 the file above the last displayed line.
372
373
374 - Followed by one of the command line option letters
375 (see below), this will change the setting of that
376 option and print a message describing the new set-
377 ting. If the option letter has a numeric value
378 (such as -b or -h), or a string value (such as -P
379 or -t), a new value may be entered after the option
380 letter. If no new value is entered, a message
381 describing the current setting is printed and noth-
382 ing is changed.
383
384
385 -+ Followed by one of the command line option letters
386 (see below), this will reset the option to its
387 default setting and print a message describing the
388 new setting. (The "-+_X" command does the same
389 thing as "-+_X" on the command line.) This does not
390 work for string-valued options.
391
392
393
394 6
395
396
397
398
399
400 LESS(1) LESS(1)
401
402
403 -- Followed by one of the command line option letters
404 (see below), this will reset the option to the
405 "opposite" of its default setting and print a mes-
406 sage describing the new setting. (The "--_X" com-
407 mand does the same thing as "-_X" on the command
408 line.) This does not work for numeric or string-
409 valued options.
410
411
412 _ (Underscore.) Followed by one of the command line
413 option letters (see below), this will print a mes-
414 sage describing the current setting of that option.
415 The setting of the option is not changed.
416
417
418 +cmd Causes the specified cmd to be executed each time a
419 new file is examined. For example, +G causes _l_e_s_s
420 to initially display each file starting at the end
421 rather than the beginning.
422
423
424 V Prints the version number of _l_e_s_s being run.
425
426
427 q or :q or :Q or ZZ or ESC ESC
428 Exits _l_e_s_s_.
429
430 The following three commands may or may not be valid,
431 depending on your particular installation.
432
433
434 v Invokes an editor to edit the current file being
435 viewed. The editor is taken from the environment
436 variable EDITOR, or defaults to "vi". See also the
437 discussion of LESSEDIT under the section on PROMPTS
438 below.
439
440
441 ! shell-command
442 Invokes a shell to run the shell-command given. A
443 percent sign (%) in the command is replaced by the
444 name of the current file. A pound sign (#) is
445 replaced by the name of the previously examined
446 file. "!!" repeats the last shell command. "!"
447 with no shell command simply invokes a shell. In
448 all cases, the shell is taken from the environment
449 variable SHELL, or defaults to "sh".
450
451
452 | <m> shell-command
453 <m> represents any mark letter. Pipes a section of
454 the input file to the given shell command. The
455 section of the file to be piped is between the
456 first line on the current screen and the position
457
458
459
460 7
461
462
463
464
465
466 LESS(1) LESS(1)
467
468
469 marked by the letter. <m> may also be ^ or $ to
470 indicate beginning or end of file respectively. If
471 <m> is . or newline, the current screen is piped.
472
473
474 OOPPTTIIOONNSS
475 Command line options are described below. Most options
476 may be changed while _l_e_s_s is running, via the "-" command.
477
478 Options are also taken from the environment variable
479 "LESS". For example, to avoid typing "less -options ..."
480 each time _l_e_s_s is invoked, you might tell _c_s_h_:
481
482 setenv LESS "-options"
483
484 or if you use _s_h_:
485
486 LESS="-options"; export LESS
487
488 The environment variable is parsed before the command
489 line, so command line options override the LESS environ-
490 ment variable. If an option appears in the LESS variable,
491 it can be reset to its default on the command line by
492 beginning the command line option with "-+".
493
494 A dollar sign ($) may be used to signal the end of an
495 option string. This is important only for options like -P
496 which take a following string.
497
498 -? This option displays a summary of the commands
499 accepted by _l_e_s_s (the same as the h command). If
500 this option is given, all other options are
501 ignored, and _l_e_s_s exits after the help screen is
502 viewed. (Depending on how your shell interprets
503 the question mark, it may be necessary to quote the
504 question mark, thus: "-\?".)
505
506 -a Causes searches to start after the last line dis-
507 played on the screen, thus skipping all lines dis-
508 played on the screen. By default, searches start
509 at the second line on the screen (or after the last
510 found line; see the -j option).
511
512 -b_n Causes _l_e_s_s to use a non-standard number of
513 buffers. Buffers are 1K, and by default 10 buffers
514 are used (except if data in coming from standard
515 input; see the -B option). The number _n specifies
516 a different number of buffers to use.
517
518 -B Disables automatic allocation of buffers, so that
519 only the default number of buffers are used. If
520 more data is read than will fit in the buffers, the
521 oldest data is discarded. By default, when data is
522 coming from standard input, buffers are allocated
523
524
525
526 8
527
528
529
530
531
532 LESS(1) LESS(1)
533
534
535 automatically as needed to avoid loss of data.
536
537 -c Causes full screen repaints to be painted from the
538 top line down. By default, full screen repaints
539 are done by scrolling from the bottom of the
540 screen.
541
542 -C The -C option is like -c, but the screen is cleared
543 before it is repainted.
544
545 -d The -d option suppresses the error message normally
546 displayed if the terminal is dumb; that is, lacks
547 some important capability, such as the ability to
548 clear the screen or scroll backward. The -d option
549 does not otherwise change the behavior of _l_e_s_s on a
550 dumb terminal).
551
552 -e Causes _l_e_s_s to automatically exit the second time
553 it reaches end-of-file. By default, the only way
554 to exit _l_e_s_s is via the "q" command.
555
556 -E Causes _l_e_s_s to automatically exit the first time it
557 reaches end-of-file.
558
559 -f Forces non-regular files to be opened. (A non-
560 regular file is a directory or a device special
561 file.) Also suppresses the warning message when a
562 binary file is opened. By default, _l_e_s_s will
563 refuse to open non-regular files.
564
565 -h_n Specifies a maximum number of lines to scroll back-
566 ward. If it is necessary to scroll backward more
567 than _n lines, the screen is repainted in a forward
568 direction instead. (If the terminal does not have
569 the ability to scroll backward, -h0 is implied.)
570
571 -i Causes searches to ignore case; that is, uppercase
572 and lowercase are considered identical. Also, text
573 which is overstruck or underlined can be searched
574 for. This option is ignored if any uppercase let-
575 ters appear in the search pattern.
576
577 -j_n Specifies a line on the screen where "target" lines
578 are to be positioned. Target lines are the object
579 of text searches, tag searches, jumps to a line
580 number, jumps to a file percentage, and jumps to a
581 marked position. The screen line is specified by a
582 number: the top line on the screen is 1, the next
583 is 2, and so on. The number may be negative to
584 specify a line relative to the bottom of the
585 screen: the bottom line on the screen is -1, the
586 second to the bottom is -2, and so on. If the -j
587 option is used, searches begin at the line immedi-
588 ately after the target line. For example, if "-j4"
589
590
591
592 9
593
594
595
596
597
598 LESS(1) LESS(1)
599
600
601 is used, the target line is the fourth line on the
602 screen, so searches begin at the fifth line on the
603 screen.
604
605 -k_f_i_l_e_n_a_m_e
606 Causes _l_e_s_s to open and interpret the named file as
607 a _l_e_s_s_k_e_y (1) file. Multiple -k options may be
608 specified. If a file called .less exists in the
609 user's home directory, this file is also used as a
610 _l_e_s_s_k_e_y file.
611
612 -m Causes _l_e_s_s to prompt verbosely (like _m_o_r_e), with
613 the percent into the file. By default, _l_e_s_s
614 prompts with a colon.
615
616 -M Causes _l_e_s_s to prompt even more verbosely than
617 _m_o_r_e_.
618
619 -n Suppresses line numbers. The default (to use line
620 numbers) may cause _l_e_s_s to run more slowly in some
621 cases, especially with a very large input file.
622 Suppressing line numbers with the -n flag will
623 avoid this problem. Using line numbers means: the
624 line number will be displayed in the verbose prompt
625 and in the = command, and the v command will pass
626 the current line number to the editor (see also the
627 discussion of LESSEDIT in PROMPTS below).
628
629 -N Causes a line number to be displayed at the begin-
630 ning of each line in the display.
631
632 -o_f_i_l_e_n_a_m_e
633 Causes _l_e_s_s to copy its input to the named file as
634 it is being viewed. This applies only when the
635 input file is a pipe, not an ordinary file. If the
636 file already exists, _l_e_s_s will ask for confirmation
637 before overwriting it.
638
639 -O_f_i_l_e_n_a_m_e
640 The -O option is like -o, but it will overwrite an
641 existing file without asking for confirmation.
642
643 If no log file has been specified, the -o and -O
644 options can be used from within _l_e_s_s to specify a
645 log file. Without a file name, they will simply
646 report the name of the log file. The "s" command
647 is equivalent to specifying -o from within _l_e_s_s_.
648
649 -p_p_a_t_t_e_r_n
650 The -p option on the command line is equivalent to
651 specifying +/_p_a_t_t_e_r_n; that is, it tells _l_e_s_s to
652 start at the first occurence of _p_a_t_t_e_r_n in the
653 file.
654
655
656
657
658 10
659
660
661
662
663
664 LESS(1) LESS(1)
665
666
667 -P_p_r_o_m_p_t
668 Provides a way to tailor the three prompt styles to
669 your own preference. This option would normally be
670 put in the LESS environment variable, rather than
671 being typed in with each _l_e_s_s command. Such an
672 option must either be the last option in the LESS
673 variable, or be terminated by a dollar sign. -P
674 followed by a string changes the default (short)
675 prompt to that string. -Pm changes the medium (-m)
676 prompt to the string, and -PM changes the long (-M)
677 prompt. Also, -P= changes the message printed by
678 the = command to the given string. All prompt
679 strings consist of a sequence of letters and spe-
680 cial escape sequences. See the section on PROMPTS
681 for more details.
682
683 -q Causes moderately "quiet" operation: the terminal
684 bell is not rung if an attempt is made to scroll
685 past the end of the file or before the beginning of
686 the file. If the terminal has a "visual bell", it
687 is used instead. The bell will be rung on certain
688 other errors, such as typing an invalid character.
689 The default is to ring the terminal bell in all
690 such cases.
691
692 -Q Causes totally "quiet" operation: the terminal bell
693 is never rung.
694
695 -r Causes "raw" control characters to be displayed.
696 The default is to display control characters using
697 the caret notation; for example, a control-A (octal
698 001) is displayed as "^A". Warning: when the -r
699 flag is used, _l_e_s_s cannot keep track of the actual
700 appearance of the screen (since this depends on how
701 the screen responds to each type of control charac-
702 ter). Thus, various display problems may result,
703 such as long lines being split in the wrong place.
704
705 -s Causes consecutive blank lines to be squeezed into
706 a single blank line. This is useful when viewing
707 _n_r_o_f_f output.
708
709 -S Causes lines longer than the screen width to be
710 chopped rather than folded. That is, the remainder
711 of a long line is simply discarded. The default is
712 to fold long lines; that is, display the remainder
713 on the next line.
714
715 -t_t_a_g The -t option, followed immediately by a TAG, will
716 edit the file containing that tag. For this to
717 work, there must be a file called "tags" in the
718 current directory, which was previously built by
719 the _c_t_a_g_s (1) command. This option may also be
720 specified from within _l_e_s_s (using the - command) as
721
722
723
724 11
725
726
727
728
729
730 LESS(1) LESS(1)
731
732
733 a way of examining a new file. The command ":t" is
734 equivalent to specifying -t from within _l_e_s_s_.
735
736 -T_t_a_g_s_f_i_l_e
737 Specifies a tags file to be used instead of "tags".
738
739 -u Causes backspaces and carriage returns to be
740 treated as printable characters; that is, they are
741 sent to the terminal when they appear in the input.
742
743 -U Causes backspaces and carriage returns to be
744 treated as control characters; that is, they are
745 handled as specified by the -r option.
746
747 By default, if neither -u nor -U is given,
748 backspaces which appear adjacent to an underscore
749 character are treated specially: the underlined
750 text is displayed using the terminal's hardware
751 underlining capability. Also, backspaces which
752 appear between two identical characters are treated
753 specially: the overstruck text is printed using the
754 terminal's hardware boldface capability. Other
755 backspaces are deleted, along with the preceding
756 character. Carriage returns immediately followed
757 by a newline are deleted. Other carriage returns
758 are handled as specified by the -r option.
759
760 -w Causes blank lines to be used to represent lines
761 past the end of the file. By default, a tilde
762 character is used.
763
764 -x_n Sets tab stops every _n positions. The default for
765 _n is 8.
766
767 -y_n Specifies a maximum number of lines to scroll for-
768 ward. If it is necessary to scroll forward more
769 than _n lines, the screen is repainted instead. The
770 -c or -C option may be used to repaint from the top
771 of the screen if desired. By default, any forward
772 movement causes scrolling.
773
774 -[z]_n Changes the default scrolling window size to _n
775 lines. The default is one screenful. The z and w
776 commands can also be used to change the window
777 size. The "z" may be omitted, as in "-_n" for com-
778 patibility with _m_o_r_e_.
779
780 + If a command line option begins with ++, the remain-
781 der of that option is taken to be an initial com-
782 mand to _l_e_s_s_. For example, +G tells _l_e_s_s to start
783 at the end of the file rather than the beginning,
784 and +/xyz tells it to start at the first occurrence
785 of "xyz" in the file. As a special case, +<number>
786 acts like +<number>g; that is, it starts the
787
788
789
790 12
791
792
793
794
795
796 LESS(1) LESS(1)
797
798
799 display at the specified line number (however, see
800 the caveat under the "g" command above). If the
801 option starts with ++, the initial command applies
802 to every file being viewed, not just the first one.
803 The + command described previously may also be used
804 to set (or change) an initial command for every
805 file.
806
807
808 KKEEYY BBIINNDDIINNGGSS
809 You may define your own _l_e_s_s commands by using the program
810 _l_e_s_s_k_e_y (1) to create a file called ".less" in your home
811 directory. This file specifies a set of command keys and
812 an action associated with each key. See the _l_e_s_s_k_e_y man-
813 ual page for more details.
814
815
816 NNAATTIIOONNAALL CCHHAARRAACCTTEERR SSEETTSS
817 There are three types of characters in the input file:
818
819 normal characters
820 can be displayed directly to the screen.
821
822 control characters
823 should not be displayed directly, but are expected
824 to be found in ordinary text files (such as
825 backspace and tab).
826
827 binary characters
828 cannot be displayed directly and are not expected
829 to be found in text files.
830
831 By default, _l_e_s_s uses the ASCII character set. In the
832 ASCII character set, characters with values between 128
833 and 255 are treated as binary. The LESSCHARSET environ-
834 ment variable may be used to select another character set.
835 If it is set to the value "latin1", the ISO 8859/1 charac-
836 ter set is assumed. Latin-1 is the same as ASCII, except
837 characters between 128 and 255 are treated as normal char-
838 acters. The only valid values for LESSCHARSET currently
839 are "ascii" and "latin1".
840
841 In special cases, it may be desired to tailor _l_e_s_s to use
842 a character set other than the ones definable by LESS-
843 CHARSET. In this case, the environment variable LESS-
844 CHARDEF can be used to define a character set. It should
845 be set to a string where each character in the string rep-
846 resents one character in the character set. The character
847 "." is used for a normal character, "c" for control, and
848 "b" for binary. A decimal number may be used for repeti-
849 tion. For example, "bccc4b." would mean character 0 is
850 binary, 1, 2 and 3 are control, 4, 5, 6 and 7 are binary,
851 and 8 is normal. All characters after the last are taken
852 to be the same as the last, so characters 9 through 255
853
854
855
856 13
857
858
859
860
861
862 LESS(1) LESS(1)
863
864
865 would be normal. (This is an example, and does not neces-
866 sarily represent any real character set.)
867
868 Setting LESSCHARDEF to "8bcccbcc18b95.b" is the same as
869 setting LESSCHARSET to "ascii". Setting LESSCHARDEF to
870 "8bcccbcc18b95.33b." is the same as setting LESSCHARSET to
871 "latin1".
872
873 Control and binary characters are displayed in blinking
874 mode. Each such character is displayed in caret notation
875 if possible (e.g. ^A for control-A). Caret notation is
876 used only if inverting the 0100 bit results in a normal
877 printable character. Otherwise, the character is dis-
878 played as an octal number preceded by a backslash. This
879 octal format can be changed by setting the LESSBINFMT
880 environment variable to a printf-style format string; the
881 default is '\%o'. The blinking mode display of control
882 and binary characters can be changed or disabled by pre-
883 ceding the LESSBINFMT format string with a "*" and one
884 character to select the mode: "*k" is blinking, "*d" is
885 bold, "*u" is underlined, and "*n" is normal (no special
886 display attribute). For example, if LESSBINFMT is
887 "*u[%x]", binary characters are displayed in underlined
888 hexadecimal surrounded by brackets.
889
890
891 PPRROOMMPPTTSS
892 The -P option allows you to tailor the prompt to your
893 preference. The string given to the -P option replaces
894 the specified prompt string. Certain characters in the
895 string are interpreted specially. The prompt mechanism is
896 rather complicated to provide flexibility, but the ordi-
897 nary user need not understand the details of constructing
898 personalized prompt strings.
899
900 A percent sign followed by a single character is expanded
901 according to what the following character is:
902
903 %b_X Replaced by the byte offset into the current input
904 file. The b is followed by a single character
905 (shown as _X above) which specifies the line whose
906 byte offset is to be used. If the character is a
907 "t", the byte offset of the top line in the display
908 is used, an "m" means use the middle line, a "b"
909 means use the bottom line, a "B" means use the line
910 just after the bottom line, and a "j" means use the
911 "target" line, as specified by the -j option.
912
913 %B Replaced by the size of the current input file.
914
915 %E Replaced by the name of the editor (from the EDITOR
916 environment variable). See the discussion of the
917 LESSEDIT feature below.
918
919
920
921
922 14
923
924
925
926
927
928 LESS(1) LESS(1)
929
930
931 %f Replaced by the name of the current input file.
932
933 %i Replaced by the index of the current file in the
934 list of input files.
935
936 %l_X Replaced by the line number of a line in the input
937 file. The line to be used is determined by the _X,
938 as with the %b option.
939
940 %L Replaced by the line number of the last line in the
941 input file.
942
943 %m Replaced by the total number of input files.
944
945 %p_X Replaced by the percent into the current input
946 file. The line used is determined by the _X as with
947 the %b option.
948
949 %s Same as %B.
950
951 %t Causes any trailing spaces to be removed. Usually
952 used at the end of the string, but may appear any-
953 where.
954
955 %x Replaced by the name of the next input file in the
956 list.
957
958 If any item is unknown (for example, the file size if
959 input is a pipe), a question mark is printed instead.
960
961 The format of the prompt string can be changed depending
962 on certain conditions. A question mark followed by a sin-
963 gle character acts like an "IF": depending on the follow-
964 ing character, a condition is evaluated. If the condition
965 is true, any characters following the question mark and
966 condition character, up to a period, are included in the
967 prompt. If the condition is false, such characters are
968 not included. A colon appearing between the question mark
969 and the period can be used to establish an "ELSE": any
970 characters between the colon and the period are included
971 in the string if and only if the IF condition is false.
972 Condition characters (which follow a question mark) may
973 be:
974
975 ?a True if any characters have been included in the
976 prompt so far.
977
978 ?b_X True if the byte offset of the specified line is
979 known.
980
981 ?B True if the size of current input file is known.
982
983 ?e True if at end-of-file.
984
985
986
987
988 15
989
990
991
992
993
994 LESS(1) LESS(1)
995
996
997 ?f True if there is an input filename (that is, if
998 input is not a pipe).
999
1000 ?l_X True if the line number of the specified line is
1001 known.
1002
1003 ?L True if the line number of the last line in the
1004 file is known.
1005
1006 ?m True if there is more than one input file.
1007
1008 ?n True if this is the first prompt in a new input
1009 file.
1010
1011 ?p_X True if the percent into the current input file of
1012 the specified line is known.
1013
1014 ?s Same as "?B".
1015
1016 ?x True if there is a next input file (that is, if the
1017 current input file is not the last one).
1018
1019 Any characters other than the special ones (question mark,
1020 colon, period, percent, and backslash) become literally
1021 part of the prompt. Any of the special characters may be
1022 included in the prompt literally by preceding it with a
1023 backslash.
1024
1025 Some examples:
1026
1027 ?f%f:Standard input.
1028
1029 This prompt prints the filename, if known; otherwise the
1030 string "Standard input".
1031
1032 ?f%f .?ltLine %lt:?pt%pt\%:?btByte %bt:-...
1033
1034 This prompt would print the filename, if known. The file-
1035 name is followed by the line number, if known, otherwise
1036 the percent if known, otherwise the byte offset if known.
1037 Otherwise, a dash is printed. Notice how each question
1038 mark has a matching period, and how the % after the %pt is
1039 included literally by escaping it with a backslash.
1040
1041 ?n?f%f .?m(file %i of %m) ..?e(END) ?x- Next\: %x..%t
1042
1043 This prints the filename if this is the first prompt in a
1044 file, followed by the "file N of N" message if there is
1045 more than one input file. Then, if we are at end-of-file,
1046 the string "(END)" is printed followed by the name of the
1047 next file, if there is one. Finally, any trailing spaces
1048 are truncated. This is the default prompt. For refer-
1049 ence, here are the defaults for the other two prompts (-m
1050 and -M respectively). Each is broken into two lines here
1051
1052
1053
1054 16
1055
1056
1057
1058
1059
1060 LESS(1) LESS(1)
1061
1062
1063 for readability only.
1064
1065 ?n?f%f .?m(file %i of %m) ..?e(END) ?x- Next\: %x.:
1066 ?pB%pB\%:byte %bB?s/%s...%t
1067
1068 ?f%f .?n?m(file %i of %m) ..?ltline %lt?L/%L. :byte %bB?s/%s. .
1069 ?e(END) ?x- Next\: %x.:?pB%pB\%..%t
1070
1071 And here is the default message produced by the = command:
1072
1073 ?f%f .?m(file %i of %m) .?ltline %lt?L/%L. .
1074 byte %bB?s/%s. ?e(END) :?pB%pB\%..%t
1075
1076 The prompt expansion features are also used for another
1077 purpose: if an environment variable LESSEDIT is defined,
1078 it is used as the command to be executed when the v com-
1079 mand is invoked. The LESSEDIT string is expanded in the
1080 same way as the prompt strings. The default value for
1081 LESSEDIT is:
1082
1083 %E ?lm+%lm. %f
1084
1085 Note that this expands to the editor name, followed by a +
1086 and the line number, followed by the file name. If your
1087 editor does not accept the "+linenumber" syntax, or has
1088 other differences in invocation syntax, the LESSEDIT vari-
1089 able can be changed to modify this default.
1090
1091
1092 EENNVVIIRROONNMMEENNTT VVAARRIIAABBLLEESS
1093 COLUMNS
1094 Sets the number of columns on the screen. Takes
1095 precedence over the number of columns specified by
1096 the TERM variable.
1097
1098 EDITOR The name of the editor (used for the v command).
1099
1100 HOME Name of the user's home directory (used to find a
1101 .less file).
1102
1103 LESS Flags which are passed to _l_e_s_s automatically.
1104
1105 LESSBINFMT
1106 Format for displaying non-printable, non-control
1107 characters.
1108
1109 LESSCHARDEF
1110 Defines a character set.
1111
1112 LESSCHARSET
1113 Selects a predefined character set.
1114
1115 LESSEDIT
1116 Editor prototype string (used for the v command).
1117
1118
1119
1120 17
1121
1122
1123
1124
1125
1126 LESS(1) LESS(1)
1127
1128
1129 See discussion under PROMPTS.
1130
1131 LESSHELP
1132 Name of the help file.
1133
1134 LINES Sets the number of lines on the screen. Takes
1135 precedence over the number of lines specified by
1136 the TERM variable.
1137
1138 SHELL The shell used to execute the ! command, as well as
1139 to expand filenames.
1140
1141 TERM The type of terminal on which _l_e_s_s is being run.
1142
1143
1144 SSEEEE AALLSSOO
1145 lesskey(1)
1146
1147
1148 WWAARRNNIINNGGSS
1149 The = command and prompts (unless changed by -P) report
1150 the line number of the line at the top of the screen, but
1151 the byte and percent of the line at the bottom of the
1152 screen.
1153
1154 If the :e command is used to name more than one file, and
1155 one of the named files has been viewed previously, the new
1156 files may be entered into the list in an unexpected order.
1157
1158 The handling of national character sets is nonstandard as
1159 well as insufficient for multibyte characters. It will
1160 probably change in a later release.
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186 18
1187
1188