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