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