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