don't pause after exiting from help file
[unix-history] / usr / src / usr.bin / more / more.1
CommitLineData
bfe13c81
KB
1.\"
2.\" Copyright (c) 1988 Mark Nudleman
3.\" Copyright (c) 1988 Regents of the University of California.
4.\" All rights reserved.
5.\"
6.\" This code is derived from software contributed to Berkeley by
7.\" Mark Nudleman.
8.\"
9.\" Redistribution and use in source and binary forms are permitted
10.\" provided that the above copyright notice and this paragraph are
11.\" duplicated in all such forms and that any documentation,
12.\" advertising materials, and other materials related to such
13.\" distribution and use acknowledge that the software was developed
14.\" by the University of California, Berkeley. The name of the
15.\" University may not be used to endorse or promote products derived
16.\" from this software without specific prior written permission.
17.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
18.\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
19.\" WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
20.\"
21.\" @(#)more.1 5.1 (Berkeley) %G%
22.\"
23.TH LESS 1
24.SH NAME
25less \- opposite of more
26.SH SYNOPSIS
27.B "less [-[+]aABcCdeEimMnqQuUsw] [-b\fIN\fB] [-h\fIN\fB] [-x\fIN\fB] [-[z]\fIN\fB]"
28.br
29.B " [-P[mM=]\fIstring\fB] [-[lL]\fIlogfile\fB] [+\fIcmd\fB]"
30.br
31.B " [-t\fItag\fB] [\fIfilename\fB]..."
32.SH DESCRIPTION
33.I Less
34is a program similar to
35.I more
36(1), but which allows backwards movement
37in the file as well as forward movement.
38Also,
39.I less
40does not have to read the entire input file before starting,
41so with large input files it starts up faster than text editors like
42.I vi
43(1).
44.I Less
45uses termcap (or terminfo on some systems),
46so it can run on a variety of terminals.
47There is even limited support for hardcopy terminals.
48(On a hardcopy terminal, lines which should be printed at the top
49of the screen are prefixed with an up-arrow.)
50.PP
51Commands are based on both
52.I more
53and
54.I vi.
55Commands may be preceeded by a decimal number,
56called N in the descriptions below.
57The number is used by some commands, as indicated.
58
59.SH COMMANDS
60In the following descriptions, ^X means control-X.
61ESC stands for the ESCAPE key; for example ESC-v means the
62two character sequence "ESCAPE", then "v".
63.IP H
64Help: display a summary of these commands.
65If you forget all the other commands, remember this one.
66.PP
67.IP "SPACE or f or ^F or ^V"
68Scroll forward N lines, default one window (see option -z below).
69If N is more than the screen size, only the final screenful is displayed.
70Warning: some systems use ^V as a special literalization character.
71.PP
72.IP "b or ^B or ESC-v"
73Scroll backward N lines, default one window (see option -z below).
74If N is more than the screen size, only the final screenful is displayed.
75.PP
76.IP "RETURN or ^N or e or ^E or j or ^J"
77Scroll forward N lines, default 1.
78The entire N lines are displayed, even if N is more than the screen size.
79.PP
80.IP "y or ^Y or ^P or k or ^K"
81Scroll backward N lines, default 1.
82The entire N lines are displayed, even if N is more than the screen size.
83Warning: some systems use ^Y as a special job control character.
84.PP
85.IP "d or ^D"
86Scroll forward N lines, default one half of the screen size.
87If N is specified, it becomes the new default for
88subsequent d and u commands.
89.PP
90.IP "u or ^U"
91Scroll backward N lines, default one half of the screen size.
92If N is specified, it becomes the new default for
93subsequent d and u commands.
94.PP
95.IP "r or ^R or ^L"
96Repaint the screen.
97.PP
98.IP R
99Repaint the screen, discarding any buffered input.
100Useful if the file is changing while it is being viewed.
101.PP
102.IP "g or < or ESC-<"
103Go to line N in the file, default 1 (beginning of file).
104(Warning: this may be slow if N is large.)
105.PP
106.IP "G or > or ESC->"
107Go to line N in the file, default the end of the file.
108(Warning: this may be slow if N is large,
109or if N is not specified and
110standard input, rather than a file, is being read.)
111.PP
112.IP "p or %"
113Go to a position N percent into the file.
114N should be between 0 and 100.
115(This works if standard input is being read, but only if
116.I less
117has already read to the end of the file.
118It is always fast, but not always useful.)
119.PP
120.IP m
121Followed by any lowercase letter,
122marks the current position with that letter.
123.PP
124.IP "'"
125(Single quote.)
126Followed by any lowercase letter, returns to the position which
127was previously marked with that letter.
128Followed by another single quote, returns to the postion at
129which the last "large" movement command was executed.
130All marks are lost when a new file is examined.
131.PP
132.IP "^X^X"
133Same as single quote.
134.PP
135.IP /pattern
136Search forward in the file for the N-th line containing the pattern.
137N defaults to 1.
138The pattern is a regular expression, as recognized by
139.I ed.
140The search starts at the second line displayed
141(but see the -a option, which changes this).
142.PP
143.IP ?pattern
144Search backward in the file for the N-th line containing the pattern.
145The search starts at the line immediately before the top line displayed.
146.PP
147.IP /!pattern
148Like /, but the search is for the N-th line
149which does NOT contain the pattern.
150.PP
151.IP ?!pattern
152Like ?, but the search is for the N-th line
153which does NOT contain the pattern.
154.PP
155.IP n
156Repeat previous search, for N-th line containing the last pattern
157(or NOT containing the last pattern, if the previous search
158was /! or ?!).
159.PP
160.IP "E [filename]"
161Examine a new file.
162If the filename is missing, the "current" file (see the N and P commands
163below) from the list of files in the command line is re-examined.
164If the filename is a pound sign (#), the previously examined file is
165re-examined.
166.PP
167.IP "^X^V or :e"
168Same as E.
169Warning: some systems use ^V as a special literalization character.
170.PP
171.IP "N or :n"
172Examine the next file (from the list of files given in the command line).
173If a number N is specified (not to be confused with the command N),
174the N-th next file is examined.
175.PP
176.IP "P or :p"
177Examine the previous file.
178If a number N is specified, the N-th previous file is examined.
179.PP
180.IP "= or ^G"
181Prints some information about the file being viewed,
182including its name
183and the line number and byte offset of the bottom line being displayed.
184If possible, it also prints the length of the file
185and the percent of the file above the last displayed line.
186.PP
187.IP \-
188Followed by one of the command line option letters (see below),
189this will change the setting of that option
190and print a message describing the new setting.
191If the option letter has a numeric value (such as -b or -h),
192or a string value (such as -P or -t),
193a new value may be entered after the option letter.
194.PP
195.IP \_
196(Underscore.)
197Followed by one of the command line option letters (see below),
198this will print a message describing the current setting of that option.
199The setting of the option is not changed.
200.PP
201.IP +cmd
202Causes the specified cmd to be executed each time a new file is examined.
203For example, +G causes
204.I less
205to initially display each file starting at the end
206rather than the beginning.
207.PP
208.IP V
209Prints the version number of
210.I less
211being run.
212.PP
213.IP "q or :q or ZZ"
214Exits
215.I less.
216.PP
217The following
218two
219commands may or may not be valid, depending on your particular installation.
220.PP
221.IP v
222Invokes an editor to edit the current file being viewed.
223The editor is taken from the environment variable EDITOR,
224or defaults to "vi".
225.PP
226.IP "! shell-command"
227Invokes a shell to run the shell-command given.
228A percent sign in the command is replaced by the name of the
229current file. "!!" repeats the last shell command.
230"!" with no shell command simply invokes a shell.
231In all cases, the shell is taken from the environment variable SHELL,
232or defaults to "sh".
233.PP
234.SH OPTIONS
235Command line options are described below.
236Most options may be changed while
237.I less
238is running, via the "\-" command.
239.PP
240Options are also taken from the environment variable "LESS".
241For example,
242to avoid typing "less -options ..." each time
243.I less
244is invoked, you might tell
245.I csh:
246.sp
247setenv LESS "-options"
248.sp
249or if you use
250.I sh:
251.sp
252LESS="-options"; export LESS
253.sp
254The environment variable is parsed before the command line,
255so command line options override the LESS environment variable.
256If an option appears in the LESS variable, it can be reset
257to its default on the command line by beginning the command
258line option with "-+".
259.sp
260A dollar sign ($) may be used to signal the end of an option string.
261This is important only for options like -P which take a
262following string.
263.IP -a
264Normally, forward searches start just after
265the top displayed line (that is, at the second displayed line).
266Thus, forward searches include the currently displayed screen.
267The -a option causes forward searches to start
268just after the bottom line displayed,
269thus skipping the currently displayed screen.
270.IP -A
271The -A option causes searches to start at the second SCREEN line
272displayed, as opposed to the default which is to start at the second
273REAL line displayed.
274For example, suppose a long real line occupies the first three screen lines.
275The default search will start at the second real line (the fourth
276screen line), while the -A option
277will cause the search to start at the second screen line (in the
278midst of the first real line).
279(This option is rarely useful.)
280.IP -b
281The -b\fIn\fR option tells
282.I less
283to use a non-standard number of buffers.
284Buffers are 1K, and normally 10 buffers are used
285(except if data in coming from standard input; see the -B option).
286The number \fIn\fR specifies a different number of buffers to use.
287.IP -B
288Normally, when data is coming from standard input,
289buffers are allocated automatically as needed, to avoid loss of data.
290The -B option disables this feature, so that only the default number
291of buffers are used.
292If more data is read than will fit in the buffers, the oldest
293data is discarded.
294.IP -c
295Normally,
296.I less
297will repaint the screen by scrolling from the bottom of the screen.
298If the -c option is set, when
299.I less
300needs to change the entire display, it will paint from the top line down.
301.IP -C
302The -C option is like -c, but the screen is cleared before it is repainted.
303.IP -d
304Normally,
305.I less
306will complain if the terminal is dumb; that is, lacks some important capability,
307such as the ability to clear the screen or scroll backwards.
308The -d option suppresses this complaint
309(but does not otherwise change the behavior of the program on a dumb terminal).
310.IP -e
311Normally the only way to exit less is via the "q" command.
312The -e option tells less to automatically exit
313the second time it reaches end-of-file.
314.IP -E
315The -E flag causes less to exit the first time it reaches end-of-file.
316.IP -h
317Normally,
318.I less
319will scroll backwards when backwards movement is necessary.
320The -h option specifies a maximum number of lines to scroll backwards.
321If it is necessary to move backwards more than this many lines,
322the screen is repainted in a forward direction.
323(If the terminal does not have the ability to scroll
324backwards, -h0 is implied.)
325.IP -i
326The -i option causes searches to ignore case; that is,
327uppercase and lowercase are considered identical.
328Also, text which is overstruck or underlined can be searched for.
329.IP -l
330The -l option, followed immediately by a filename,
331will cause
332.I less
333to copy its input to the named file as it is being viewed.
334This applies only when the input file is a pipe,
335not an ordinary file.
336If the file already exists, less will ask for confirmation before
337overwriting it.
338.IP -L
339The -L option is like -l, but it will overwrite an existing
340file without asking for confirmation.
341.sp
342If no log file has been specified,
343the -l and -L options can be used from within less to specify a log file.
344Without a file name, they will simply report the name of the log file.
345.IP -m
346Normally,
347.I less
348prompts with a colon.
349The -m option causes
350.I less
351to prompt verbosely (like
352.I more),
353with the percent into the file.
354.IP -M
355The -M option causes
356.I less
357to prompt even more verbosely than
358.I more.
359.IP -n
360The -n flag suppresses line numbers.
361The default (to use line numbers) may cause
362.I less
363to run more slowly in some cases, especially with a very large input file.
364Suppressing line numbers with the -n flag will avoid this problem.
365Using line numbers means: the line number will be displayed in the verbose
366prompt and in the = command,
367and the v command will pass the current line number to the editor.
368.IP -P
369The -P option provides a way to tailor the three prompt
370styles to your own preference.
371You would normally put this option in your LESS environment
372variable, rather than type it in with each less command.
373Such an option must either be the last option in the LESS variable,
374or be terminated by a dollar sign.
375-P followed by a string changes the default (short) prompt to that string.
376-Pm changes the medium (-m) prompt to the string, and
377-PM changes the long (-M) prompt.
378Also, -P= changes the message printed by the = command to the given string.
379All prompt strings consist of a sequence of
380letters and special escape sequences.
381See the section on PROMPTS for more details.
382.IP -q
383Normally, if an attempt is made to scroll past the end of the file
384or before the beginning of the file, the terminal bell is rung to
385indicate this fact.
386The -q option tells
387.I less
388not to ring the bell at such times.
389If the terminal has a "visual bell", it is used instead.
390.IP -Q
391Even if -q is given,
392.I less
393will ring the bell on certain other errors,
394such as typing an invalid character.
395The -Q option tells
396.I less
397to be quiet all the time; that is, never ring the terminal bell.
398If the terminal has a "visual bell", it is used instead.
399.IP -s
400The -s option causes
401consecutive blank lines to be squeezed into a single blank line.
402This is useful when viewing
403.I nroff
404output.
405.IP -t
406The -t option, followed immediately by a TAG,
407will edit the file containing that tag.
408For this to work, there must be a file called "tags" in the
409current directory, which was previously built by the
410.I ctags
411(1) command.
412This option may also be specified from within less
413(using the \- command) as a way of examining a new file.
414.IP -u
415If the -u option is given,
416backspaces are treated as printable characters;
417that is, they are sent to the terminal when they appear in the input.
418.IP -U
419If the -U option is given,
420backspaces are printed as the two character sequence "^H".
421.sp
422If neither -u nor -U is given,
423backspaces which appear adjacent to an underscore character
424are treated specially:
425the underlined text is displayed
426using the terminal's hardware underlining capability.
427Also, backspaces which appear between two identical characters
428are treated specially:
429the overstruck text is printed
430using the terminal's hardware boldface capability.
431Other backspaces are deleted, along with the preceeding character.
432.IP -w
433Normally,
434.I less
435uses a tilde character to represent lines past the end of the file.
436The -w option causes blank lines to be used instead.
437.IP -x
438The -x\fIn\fR option sets tab stops every \fIn\fR positions.
439The default for \fIn\fR is 8.
440.IP -[z]
441When given a backwards or forwards window command,
442.I less
443will by
444default scroll backwards or forwards one screenful of lines.
445The -z\fIn\fR option changes the default scrolling window size
446to \fIn\fR lines.
447Note that the "z" is optional for compatibility with
448.I more.
449.IP +
450If a command line option begins with \fB+\fR,
451the remainder of that option is taken to be an initial command to
452.I less.
453For example, +G tells
454.I less
455to start at the end of the file rather than the beginning,
456and +/xyz tells it to start at the first occurence of "xyz" in the file.
457As a special case, +<number> acts like +<number>g;
458that is, it starts the display at the specified line number
459(however, see the caveat under the "g" command above).
460If the option starts with \fB++\fR, the initial command applies to
461every file being viewed, not just the first one.
462The + command described previously
463may also be used to set (or change) an initial command for every file.
464
465.SH "KEY BINDINGS"
466You may define your own less commands by using the program
467.I lesskey
468(1)
469to create a file called ".less" in your home directory.
470This file specifies a set of command keys and an action
471associated with each key.
472See the
473.I lesskey
474manual page for more details.
475
476.SH "PROMPTS"
477The -P option allows you to tailor the prompt to your preference.
478The string given to the -P option replaces the specified prompt string.
479Certain characters in the string are interpreted specially.
480The prompt mechanism is rather complicated to provide flexibility,
481but the ordinary user need not understand the details of constructing
482personalized prompt strings.
483.sp
484A percent sign followed by a single character is expanded
485according to what the following character is:
486.IP "%bX"
487Replaced by the byte offset into the current input file.
488The b is followed by a single character (shown as X above)
489which specifies the line whose byte offset is to be used.
490If the character is a "t", the byte offset of the top line in the
491display is used,
492an "m" means use the middle line,
493a "b" means use the bottom line,
494and a "B" means use the line just after the bottom line.
495.IP "%f"
496Replaced by the name of the current input file.
497.IP "%i"
498Replaced by the index of the current file in the list of
499input files.
500.IP "%lX"
501Replaced by the line number of a line in the input file.
502The line to be used is determined by the X, as with the %b option.
503.IP "%m"
504Replaced by the total number of input files.
505.IP "%pX"
506Replaced by the percent into the current input file.
507The line used is determined by the X as with the %b option.
508.IP "%s"
509Replaced by the size of the current input file.
510.IP "%t"
511Causes any trailing spaces to be removed.
512Usually used at the end of the string, but may appear anywhere.
513.IP "%x"
514Replaced by the name of the next input file in the list.
515.PP
516If any item is unknown (for example, the file size if input
517is a pipe), a question mark is printed instead.
518.PP
519The format of the prompt string can be changed
520depending on certain conditions.
521A question mark followed by a single character acts like an "IF":
522depending on the following character, a condition is evaluated.
523If the condition is true, any characters following the question mark
524and condition character, up to a period, are included in the prompt.
525If the condition is false, such characters are not included.
526A colon appearing between the question mark and the
527period can be used to establish an "ELSE": any characters between
528the colon and the period are included in the string if and only if
529the IF condition is false.
530Condition characters (which follow a question mark) may be:
531.IP "?a"
532True if any characters have been included in the prompt so far.
533.IP "?bX"
534True if the byte offset of the specified line is known.
535.IP "?e"
536True if at end-of-file.
537.IP "?f"
538True if there is an input filename
539(that is, if input is not a pipe).
540.IP "?lX"
541True if the line number of the specified line is known.
542.IP "?m"
543True if there is more than one input file.
544.IP "?n"
545True if this is the first prompt in a new input file.
546.IP "?pX"
547True if the percent into the current input file
548of the specified line is known.
549.IP "?s"
550True if the size of current input file is known.
551.IP "?x"
552True if there is a next input file
553(that is, if the current input file is not the last one).
554.PP
555Any characters other than the special ones
556(question mark, colon, period, percent, and backslash)
557become literally part of the prompt.
558Any of the special characters may be included in the prompt literally
559by preceeding it with a backslash.
560.PP
561Some examples:
562.sp
563?f%f:Standard input.
564.sp
565This prompt prints the filename, if known;
566otherwise the string "Standard input".
567.sp
568?f%f .?ltLine %lt:?pt%pt\%:?btByte %bt:-...
569.sp
570This prompt would print the filename, if known.
571The filename is followed by the line number, if known,
572otherwise the percent if known, otherwise the byte offset if known.
573Otherwise, a dash is printed.
574Notice how each question mark has a matching period,
575and how the % after the %pt
576is included literally by escaping it with a backslash.
577.sp
578?n?f%f\ .?m(file\ %i\ of\ %m)\ ..?e(END)\ ?x-\ Next\\:\ %x..%t
579.sp
580This prints the filename if this is the first prompt in a file,
581followed by the "file N of N" message if there is more
582than one input file.
583Then, if we are at end-of-file, the string "(END)" is printed
584followed by the name of the next file, if there is one.
585Finally, any trailing spaces are truncated.
586This is the default prompt.
587For reference, here are the defaults for
588the other two prompts (-m and -M respectively).
589Each is broken into two lines here for readability only.
590.nf
591.sp
592?n?f%f\ .?m(file\ %i\ of\ %m)\ ..?e(END)\ ?x-\ Next\\:\ %x.:
593 ?pB%pB\\%:byte\ %bB?s/%s...%t
594.sp
595?f%f\ .?n?m(file\ %i\ of\ %m)\ ..?ltline\ %lt\ :byte\ %bB?s/%s\ ..
596 ?e(END)\ ?x-\ Next\\:\ %x.:?pB%pB\\%..%t
597.sp
598.fi
599And here is the default message produced by the = command:
600.nf
601.sp
602?f%f\ .?m(file\ %i\ of\ %m)\ .?ltline\ %lt\ .
603 byte\ %bB?s/%s.\ ?e(END)\ :?pB%pB\\%..%t
604.fi
605
606.SH "SEE ALSO"
607lesskey(1)
608
609.SH WARNINGS
610The = command and prompts (unless changed by -P)
611report the line number of the line at the top of the screen,
612but the byte and percent of the line at the bottom of the screen.