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