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