1161475SdelphijLESS(1) LESS(1) 260786Sps 360786Sps 460786Sps 5170256Sdelphij[1mNAME[0m 660786Sps less - opposite of more 760786Sps 8170256Sdelphij[1mSYNOPSIS[0m 9170256Sdelphij [1mless -?[0m 10170256Sdelphij [1mless --help[0m 11170256Sdelphij [1mless -V[0m 12170256Sdelphij [1mless --version[0m 13221715Sdelphij [1mless [-[+]aABcCdeEfFgGiIJKLmMnNqQrRsSuUVwWX~][0m 14170256Sdelphij [1m[-b [4m[22mspace[24m[1m] [-h [4m[22mlines[24m[1m] [-j [4m[22mline[24m[1m] [-k [4m[22mkeyfile[24m[1m][0m 15170256Sdelphij [1m[-{oO} [4m[22mlogfile[24m[1m] [-p [4m[22mpattern[24m[1m] [-P [4m[22mprompt[24m[1m] [-t [4m[22mtag[24m[1m][0m 16170256Sdelphij [1m[-T [4m[22mtagsfile[24m[1m] [-x [4m[22mtab[24m[1m,...] [-y [4m[22mlines[24m[1m] [-[z] [4m[22mlines[24m[1m][0m 17170256Sdelphij [1m[-# [4m[22mshift[24m[1m] [+[+][4m[22mcmd[24m[1m] [--] [[4m[22mfilename[24m[1m]...[0m 18161475Sdelphij (See the OPTIONS section for alternate option syntax with long option 19161475Sdelphij names.) 2060786Sps 2160786Sps 22170256Sdelphij[1mDESCRIPTION[0m 23170256Sdelphij [4mLess[24m is a program similar to [4mmore[24m (1), but which allows backward move- 24170256Sdelphij ment in the file as well as forward movement. Also, [4mless[24m does not have 25161475Sdelphij to read the entire input file before starting, so with large input 26170256Sdelphij files it starts up faster than text editors like [4mvi[24m (1). [4mLess[24m uses 27161475Sdelphij termcap (or terminfo on some systems), so it can run on a variety of 28161475Sdelphij terminals. There is even limited support for hardcopy terminals. (On 29161475Sdelphij a hardcopy terminal, lines which should be printed at the top of the 30161475Sdelphij screen are prefixed with a caret.) 3160786Sps 32170256Sdelphij Commands are based on both [4mmore[24m and [4mvi.[24m Commands may be preceded by a 33161475Sdelphij decimal number, called N in the descriptions below. The number is used 34161475Sdelphij by some commands, as indicated. 3560786Sps 3660786Sps 37170256Sdelphij[1mCOMMANDS[0m 38161475Sdelphij In the following descriptions, ^X means control-X. ESC stands for the 39161475Sdelphij ESCAPE key; for example ESC-v means the two character sequence 40161475Sdelphij "ESCAPE", then "v". 4160786Sps 42161475Sdelphij h or H Help: display a summary of these commands. If you forget all 43161475Sdelphij the other commands, remember this one. 4460786Sps 4560786Sps SPACE or ^V or f or ^F 46161475Sdelphij Scroll forward N lines, default one window (see option -z 47161475Sdelphij below). If N is more than the screen size, only the final 48161475Sdelphij screenful is displayed. Warning: some systems use ^V as a spe- 49161475Sdelphij cial literalization character. 5060786Sps 51161475Sdelphij z Like SPACE, but if N is specified, it becomes the new window 52161475Sdelphij size. 5360786Sps 5460786Sps ESC-SPACE 55161475Sdelphij Like SPACE, but scrolls a full screenful, even if it reaches 56161475Sdelphij end-of-file in the process. 5760786Sps 58221715Sdelphij ENTER or RETURN or ^N or e or ^E or j or ^J 59161475Sdelphij Scroll forward N lines, default 1. The entire N lines are dis- 60161475Sdelphij played, even if N is more than the screen size. 6160786Sps 6260786Sps d or ^D 63161475Sdelphij Scroll forward N lines, default one half of the screen size. If 64161475Sdelphij N is specified, it becomes the new default for subsequent d and 65161475Sdelphij u commands. 6660786Sps 6760786Sps b or ^B or ESC-v 68161475Sdelphij Scroll backward N lines, default one window (see option -z 69161475Sdelphij below). If N is more than the screen size, only the final 70161475Sdelphij screenful is displayed. 7160786Sps 72161475Sdelphij w Like ESC-v, but if N is specified, it becomes the new window 73161475Sdelphij size. 7460786Sps 7560786Sps y or ^Y or ^P or k or ^K 76161475Sdelphij Scroll backward N lines, default 1. The entire N lines are dis- 77161475Sdelphij played, even if N is more than the screen size. Warning: some 78161475Sdelphij systems use ^Y as a special job control character. 7960786Sps 8060786Sps u or ^U 81161475Sdelphij Scroll backward N lines, default one half of the screen size. 82161475Sdelphij If N is specified, it becomes the new default for subsequent d 83161475Sdelphij and u commands. 8460786Sps 8560786Sps ESC-) or RIGHTARROW 86161475Sdelphij Scroll horizontally right N characters, default half the screen 87161475Sdelphij width (see the -# option). If a number N is specified, it 88161475Sdelphij becomes the default for future RIGHTARROW and LEFTARROW com- 89161475Sdelphij mands. While the text is scrolled, it acts as though the -S 9089019Sps option (chop lines) were in effect. 9160786Sps 9260786Sps ESC-( or LEFTARROW 93161475Sdelphij Scroll horizontally left N characters, default half the screen 94161475Sdelphij width (see the -# option). If a number N is specified, it 95161475Sdelphij becomes the default for future RIGHTARROW and LEFTARROW com- 96161475Sdelphij mands. 9760786Sps 9860786Sps r or ^R or ^L 9960786Sps Repaint the screen. 10060786Sps 101161475Sdelphij R Repaint the screen, discarding any buffered input. Useful if 102161475Sdelphij the file is changing while it is being viewed. 10360786Sps 104161475Sdelphij F Scroll forward, and keep trying to read when the end of file is 105161475Sdelphij reached. Normally this command would be used when already at 106161475Sdelphij the end of the file. It is a way to monitor the tail of a file 107161475Sdelphij which is growing while it is being viewed. (The behavior is 10860786Sps similar to the "tail -f" command.) 10960786Sps 110240121Sdelphij ESC-F Like F, but as soon as a line is found which matches the last 111240121Sdelphij search pattern, the terminal bell is rung and forward scrolling 112240121Sdelphij stops. 113240121Sdelphij 11460786Sps g or < or ESC-< 115161475Sdelphij Go to line N in the file, default 1 (beginning of file). (Warn- 116161475Sdelphij ing: this may be slow if N is large.) 11760786Sps 11860786Sps G or > or ESC-> 119161475Sdelphij Go to line N in the file, default the end of the file. (Warn- 120161475Sdelphij ing: this may be slow if N is large, or if N is not specified 121161475Sdelphij and standard input, rather than a file, is being read.) 12260786Sps 123161475Sdelphij p or % Go to a position N percent into the file. N should be between 0 124170256Sdelphij and 100, and may contain a decimal point. 12560786Sps 126170256Sdelphij P Go to the line containing byte offset N in the file. 127170256Sdelphij 128161475Sdelphij { If a left curly bracket appears in the top line displayed on the 129161475Sdelphij screen, the { command will go to the matching right curly 130161475Sdelphij bracket. The matching right curly bracket is positioned on the 131161475Sdelphij bottom line of the screen. If there is more than one left curly 132161475Sdelphij bracket on the top line, a number N may be used to specify the 133161475Sdelphij N-th bracket on the line. 13460786Sps 135161475Sdelphij } If a right curly bracket appears in the bottom line displayed on 136161475Sdelphij the screen, the } command will go to the matching left curly 137161475Sdelphij bracket. The matching left curly bracket is positioned on the 138161475Sdelphij top line of the screen. If there is more than one right curly 139161475Sdelphij bracket on the top line, a number N may be used to specify the 140161475Sdelphij N-th bracket on the line. 14160786Sps 142161475Sdelphij ( Like {, but applies to parentheses rather than curly brackets. 14360786Sps 144161475Sdelphij ) Like }, but applies to parentheses rather than curly brackets. 14560786Sps 146161475Sdelphij [ Like {, but applies to square brackets rather than curly brack- 147161475Sdelphij ets. 14860786Sps 149161475Sdelphij ] Like }, but applies to square brackets rather than curly brack- 150161475Sdelphij ets. 15160786Sps 152161475Sdelphij ESC-^F Followed by two characters, acts like {, but uses the two char- 153161475Sdelphij acters as open and close brackets, respectively. For example, 154161475Sdelphij "ESC ^F < >" could be used to go forward to the > which matches 155161475Sdelphij the < in the top displayed line. 15660786Sps 157161475Sdelphij ESC-^B Followed by two characters, acts like }, but uses the two char- 158161475Sdelphij acters as open and close brackets, respectively. For example, 159161475Sdelphij "ESC ^B < >" could be used to go backward to the < which matches 160161475Sdelphij the > in the bottom displayed line. 16160786Sps 162161475Sdelphij m Followed by any lowercase letter, marks the current position 163161475Sdelphij with that letter. 16460786Sps 165161475Sdelphij ' (Single quote.) Followed by any lowercase letter, returns to 166161475Sdelphij the position which was previously marked with that letter. Fol- 167161475Sdelphij lowed by another single quote, returns to the position at which 168161475Sdelphij the last "large" movement command was executed. Followed by a ^ 169161475Sdelphij or $, jumps to the beginning or end of the file respectively. 170161475Sdelphij Marks are preserved when a new file is examined, so the ' com- 171161475Sdelphij mand can be used to switch between input files. 17260786Sps 17360786Sps ^X^X Same as single quote. 17460786Sps 17560786Sps /pattern 176161475Sdelphij Search forward in the file for the N-th line containing the pat- 177161475Sdelphij tern. N defaults to 1. The pattern is a regular expression, as 178161475Sdelphij recognized by the regular expression library supplied by your 179221715Sdelphij system. The search starts at the first line displayed (but see 18060786Sps the -a and -j options, which change this). 18160786Sps 182161475Sdelphij Certain characters are special if entered at the beginning of 183161475Sdelphij the pattern; they modify the type of search rather than become 184161475Sdelphij part of the pattern: 18560786Sps 18660786Sps ^N or ! 187161475Sdelphij Search for lines which do NOT match the pattern. 18860786Sps 18960786Sps ^E or * 190161475Sdelphij Search multiple files. That is, if the search reaches 191161475Sdelphij the END of the current file without finding a match, the 192161475Sdelphij search continues in the next file in the command line 19360786Sps list. 19460786Sps 19560786Sps ^F or @ 196161475Sdelphij Begin the search at the first line of the FIRST file in 197161475Sdelphij the command line list, regardless of what is currently 198161475Sdelphij displayed on the screen or the settings of the -a or -j 19960786Sps options. 20060786Sps 201161475Sdelphij ^K Highlight any text which matches the pattern on the cur- 202191930Sdelphij rent screen, but don't move to the first match (KEEP cur- 203191930Sdelphij rent position). 20460786Sps 205161475Sdelphij ^R Don't interpret regular expression metacharacters; that 206161475Sdelphij is, do a simple textual comparison. 20760786Sps 20863128Sps ?pattern 209161475Sdelphij Search backward in the file for the N-th line containing the 210161475Sdelphij pattern. The search starts at the line immediately before the 211161475Sdelphij top line displayed. 21263128Sps 21360786Sps Certain characters are special as in the / command: 21460786Sps 21560786Sps ^N or ! 216161475Sdelphij Search for lines which do NOT match the pattern. 21760786Sps 21860786Sps ^E or * 219161475Sdelphij Search multiple files. That is, if the search reaches 220161475Sdelphij the beginning of the current file without finding a 221161475Sdelphij match, the search continues in the previous file in the 222161475Sdelphij command line list. 22360786Sps 22460786Sps ^F or @ 225161475Sdelphij Begin the search at the last line of the last file in the 226161475Sdelphij command line list, regardless of what is currently dis- 227161475Sdelphij played on the screen or the settings of the -a or -j 22860786Sps options. 22960786Sps 23060786Sps ^K As in forward searches. 23160786Sps 23260786Sps ^R As in forward searches. 23360786Sps 23460786Sps ESC-/pattern 23560786Sps Same as "/*". 23660786Sps 23760786Sps ESC-?pattern 23860786Sps Same as "?*". 23960786Sps 240161475Sdelphij n Repeat previous search, for N-th line containing the last pat- 241161475Sdelphij tern. If the previous search was modified by ^N, the search is 242161475Sdelphij made for the N-th line NOT containing the pattern. If the pre- 243161475Sdelphij vious search was modified by ^E, the search continues in the 244161475Sdelphij next (or previous) file if not satisfied in the current file. 245161475Sdelphij If the previous search was modified by ^R, the search is done 246161475Sdelphij without using regular expressions. There is no effect if the 247161475Sdelphij previous search was modified by ^F or ^K. 24860786Sps 249161475Sdelphij N Repeat previous search, but in the reverse direction. 25060786Sps 251161475Sdelphij ESC-n Repeat previous search, but crossing file boundaries. The 252161475Sdelphij effect is as if the previous search were modified by *. 25360786Sps 254161475Sdelphij ESC-N Repeat previous search, but in the reverse direction and cross- 255161475Sdelphij ing file boundaries. 25660786Sps 257161475Sdelphij ESC-u Undo search highlighting. Turn off highlighting of strings 258161475Sdelphij matching the current search pattern. If highlighting is already 259161475Sdelphij off because of a previous ESC-u command, turn highlighting back 260161475Sdelphij on. Any search command will also turn highlighting back on. 261161475Sdelphij (Highlighting can also be disabled by toggling the -G option; in 262161475Sdelphij that case search commands do not turn highlighting back on.) 26360786Sps 264191930Sdelphij &pattern 265191930Sdelphij Display only lines which match the pattern; lines which do not 266191930Sdelphij match the pattern are not displayed. If pattern is empty (if 267191930Sdelphij you type & immediately followed by ENTER), any filtering is 268191930Sdelphij turned off, and all lines are displayed. While filtering is in 269191930Sdelphij effect, an ampersand is displayed at the beginning of the 270191930Sdelphij prompt, as a reminder that some lines in the file may be hidden. 271191930Sdelphij 272191930Sdelphij Certain characters are special as in the / command: 273191930Sdelphij 274191930Sdelphij ^N or ! 275191930Sdelphij Display only lines which do NOT match the pattern. 276191930Sdelphij 277221715Sdelphij ^R Don't interpret regular expression metacharacters; that 278191930Sdelphij is, do a simple textual comparison. 279191930Sdelphij 28060786Sps :e [filename] 281221715Sdelphij Examine a new file. If the filename is missing, the "current" 282221715Sdelphij file (see the :n and :p commands below) from the list of files 283221715Sdelphij in the command line is re-examined. A percent sign (%) in the 284221715Sdelphij filename is replaced by the name of the current file. A pound 285221715Sdelphij sign (#) is replaced by the name of the previously examined 286221715Sdelphij file. However, two consecutive percent signs are simply 287161475Sdelphij replaced with a single percent sign. This allows you to enter a 288221715Sdelphij filename that contains a percent sign in the name. Similarly, 289221715Sdelphij two consecutive pound signs are replaced with a single pound 290221715Sdelphij sign. The filename is inserted into the command line list of 291221715Sdelphij files so that it can be seen by subsequent :n and :p commands. 292161475Sdelphij If the filename consists of several files, they are all inserted 293221715Sdelphij into the list of files and the first one is examined. If the 294161475Sdelphij filename contains one or more spaces, the entire filename should 295161475Sdelphij be enclosed in double quotes (also see the -" option). 29660786Sps 29760786Sps ^X^V or E 298221715Sdelphij Same as :e. Warning: some systems use ^V as a special literal- 299221715Sdelphij ization character. On such systems, you may not be able to use 300161475Sdelphij ^V. 30160786Sps 302221715Sdelphij :n Examine the next file (from the list of files given in the com- 303221715Sdelphij mand line). If a number N is specified, the N-th next file is 304161475Sdelphij examined. 30560786Sps 306161475Sdelphij :p Examine the previous file in the command line list. If a number 307161475Sdelphij N is specified, the N-th previous file is examined. 30860786Sps 309221715Sdelphij :x Examine the first file in the command line list. If a number N 310161475Sdelphij is specified, the N-th file in the list is examined. 31160786Sps 31260786Sps :d Remove the current file from the list of files. 31360786Sps 314221715Sdelphij t Go to the next tag, if there were more than one matches for the 315161475Sdelphij current tag. See the -t option for more details about tags. 31660786Sps 317221715Sdelphij T Go to the previous tag, if there were more than one matches for 318161475Sdelphij the current tag. 31960786Sps 32089019Sps = or ^G or :f 321221715Sdelphij Prints some information about the file being viewed, including 322221715Sdelphij its name and the line number and byte offset of the bottom line 323221715Sdelphij being displayed. If possible, it also prints the length of the 324221715Sdelphij file, the number of lines in the file and the percent of the 325161475Sdelphij file above the last displayed line. 32660786Sps 327221715Sdelphij - Followed by one of the command line option letters (see OPTIONS 328221715Sdelphij below), this will change the setting of that option and print a 329221715Sdelphij message describing the new setting. If a ^P (CONTROL-P) is 330161475Sdelphij entered immediately after the dash, the setting of the option is 331221715Sdelphij changed but no message is printed. If the option letter has a 332221715Sdelphij numeric value (such as -b or -h), or a string value (such as -P 333221715Sdelphij or -t), a new value may be entered after the option letter. If 334221715Sdelphij no new value is entered, a message describing the current set- 335161475Sdelphij ting is printed and nothing is changed. 33660786Sps 337221715Sdelphij -- Like the - command, but takes a long option name (see OPTIONS 338221715Sdelphij below) rather than a single option letter. You must press ENTER 339221715Sdelphij or RETURN after typing the option name. A ^P immediately after 340221715Sdelphij the second dash suppresses printing of a message describing the 341221715Sdelphij new setting, as in the - command. 34260786Sps 343221715Sdelphij -+ Followed by one of the command line option letters this will 344221715Sdelphij reset the option to its default setting and print a message 345221715Sdelphij describing the new setting. (The "-+[4mX[24m" command does the same 346221715Sdelphij thing as "-+[4mX[24m" on the command line.) This does not work for 34760786Sps string-valued options. 34860786Sps 349221715Sdelphij --+ Like the -+ command, but takes a long option name rather than a 350161475Sdelphij single option letter. 35160786Sps 352221715Sdelphij -! Followed by one of the command line option letters, this will 353221715Sdelphij reset the option to the "opposite" of its default setting and 354221715Sdelphij print a message describing the new setting. This does not work 355161475Sdelphij for numeric or string-valued options. 35660786Sps 357221715Sdelphij --! Like the -! command, but takes a long option name rather than a 358161475Sdelphij single option letter. 35960786Sps 360221715Sdelphij _ (Underscore.) Followed by one of the command line option let- 361221715Sdelphij ters, this will print a message describing the current setting 362161475Sdelphij of that option. The setting of the option is not changed. 36360786Sps 364161475Sdelphij __ (Double underscore.) Like the _ (underscore) command, but takes 365161475Sdelphij a long option name rather than a single option letter. You must 366221715Sdelphij press ENTER or RETURN after typing the option name. 36760786Sps 368221715Sdelphij +cmd Causes the specified cmd to be executed each time a new file is 369170256Sdelphij examined. For example, +G causes [4mless[24m to initially display each 370161475Sdelphij file starting at the end rather than the beginning. 37160786Sps 372170256Sdelphij V Prints the version number of [4mless[24m being run. 37360786Sps 37460786Sps q or Q or :q or :Q or ZZ 375170256Sdelphij Exits [4mless.[0m 37660786Sps 377221715Sdelphij The following four commands may or may not be valid, depending on your 378161475Sdelphij particular installation. 37960786Sps 380221715Sdelphij v Invokes an editor to edit the current file being viewed. The 381161475Sdelphij editor is taken from the environment variable VISUAL if defined, 382221715Sdelphij or EDITOR if VISUAL is not defined, or defaults to "vi" if nei- 383221715Sdelphij ther VISUAL nor EDITOR is defined. See also the discussion of 38460786Sps LESSEDIT under the section on PROMPTS below. 38560786Sps 38660786Sps ! shell-command 387221715Sdelphij Invokes a shell to run the shell-command given. A percent sign 388221715Sdelphij (%) in the command is replaced by the name of the current file. 389161475Sdelphij A pound sign (#) is replaced by the name of the previously exam- 390221715Sdelphij ined file. "!!" repeats the last shell command. "!" with no 391221715Sdelphij shell command simply invokes a shell. On Unix systems, the 392221715Sdelphij shell is taken from the environment variable SHELL, or defaults 393221715Sdelphij to "sh". On MS-DOS and OS/2 systems, the shell is the normal 394161475Sdelphij command processor. 39560786Sps 39660786Sps | <m> shell-command 397221715Sdelphij <m> represents any mark letter. Pipes a section of the input 398221715Sdelphij file to the given shell command. The section of the file to be 399221715Sdelphij piped is between the first line on the current screen and the 400221715Sdelphij position marked by the letter. <m> may also be ^ or $ to indi- 401161475Sdelphij cate beginning or end of file respectively. If <m> is . or new- 402161475Sdelphij line, the current screen is piped. 40360786Sps 40460786Sps s filename 405221715Sdelphij Save the input to a file. This only works if the input is a 406161475Sdelphij pipe, not an ordinary file. 40760786Sps 408170256Sdelphij[1mOPTIONS[0m 409221715Sdelphij Command line options are described below. Most options may be changed 410170256Sdelphij while [4mless[24m is running, via the "-" command. 41189019Sps 412221715Sdelphij Most options may be given in one of two forms: either a dash followed 413221715Sdelphij by a single letter, or two dashes followed by a long option name. A 414221715Sdelphij long option name may be abbreviated as long as the abbreviation is 415161475Sdelphij unambiguous. For example, --quit-at-eof may be abbreviated --quit, but 416161475Sdelphij not --qui, since both --quit-at-eof and --quiet begin with --qui. Some 417221715Sdelphij long option names are in uppercase, such as --QUIT-AT-EOF, as distinct 418221715Sdelphij from --quit-at-eof. Such option names need only have their first let- 419221715Sdelphij ter capitalized; the remainder of the name may be in either case. For 420170256Sdelphij example, --Quit-at-eof is equivalent to --QUIT-AT-EOF. 42160786Sps 422161475Sdelphij Options are also taken from the environment variable "LESS". For exam- 423170256Sdelphij ple, to avoid typing "less -options ..." each time [4mless[24m is invoked, you 424170256Sdelphij might tell [4mcsh:[0m 42560786Sps 42660786Sps setenv LESS "-options" 42760786Sps 428170256Sdelphij or if you use [4msh:[0m 42960786Sps 43060786Sps LESS="-options"; export LESS 43160786Sps 432221715Sdelphij On MS-DOS, you don't need the quotes, but you should replace any per- 433161475Sdelphij cent signs in the options string by double percent signs. 43460786Sps 435221715Sdelphij The environment variable is parsed before the command line, so command 436221715Sdelphij line options override the LESS environment variable. If an option 437221715Sdelphij appears in the LESS variable, it can be reset to its default value on 438161475Sdelphij the command line by beginning the command line option with "-+". 43960786Sps 440251154Sdelphij Some options like -k or -D require a string to follow the option let- 441251154Sdelphij ter. The string for that option is considered to end when a dollar 442251154Sdelphij sign ($) is found. For example, you can set two -D options on MS-DOS 443161475Sdelphij like this: 44460786Sps 445251154Sdelphij LESS="Dn9.1$Ds4.1" 44660786Sps 447251154Sdelphij If the --use-backslash option appears earlier in the options, then a 448251154Sdelphij dollar sign or backslash may be included literally in an option string 449251154Sdelphij by preceding it with a backslash. If the --use-backslash option is not 450251154Sdelphij in effect, then backslashes are not treated specially, and there is no 451251154Sdelphij way to include a dollar sign in the option string. 45260786Sps 45360786Sps -? or --help 454221715Sdelphij This option displays a summary of the commands accepted by [4mless[0m 455221715Sdelphij (the same as the h command). (Depending on how your shell 456221715Sdelphij interprets the question mark, it may be necessary to quote the 457161475Sdelphij question mark, thus: "-\?".) 45860786Sps 45960786Sps -a or --search-skip-screen 460221715Sdelphij By default, forward searches start at the top of the displayed 461221715Sdelphij screen and backwards searches start at the bottom of the dis- 462221715Sdelphij played screen (except for repeated searches invoked by the n or 463221715Sdelphij N commands, which start after or before the "target" line 464221715Sdelphij respectively; see the -j option for more about the target line). 465221715Sdelphij The -a option causes forward searches to instead start at the 466221715Sdelphij bottom of the screen and backward searches to start at the top 467221715Sdelphij of the screen, thus skipping all lines displayed on the screen. 46860786Sps 469221715Sdelphij -A or --SEARCH-SKIP-SCREEN 470221715Sdelphij Causes all forward searches (not just non-repeated searches) to 471221715Sdelphij start just after the target line, and all backward searches to 472221715Sdelphij start just before the target line. Thus, forward searches will 473221715Sdelphij skip part of the displayed screen (from the first line up to and 474221715Sdelphij including the target line). Similarly backwards searches will 475221715Sdelphij skip the displayed screen from the last line up to and including 476221715Sdelphij the target line. This was the default behavior in less versions 477221715Sdelphij prior to 441. 478221715Sdelphij 479170256Sdelphij -b[4mn[24m or --buffers=[4mn[0m 480191930Sdelphij Specifies the amount of buffer space [4mless[24m will use for each 481191930Sdelphij file, in units of kilobytes (1024 bytes). By default 64K of 482191930Sdelphij buffer space is used for each file (unless the file is a pipe; 483191930Sdelphij see the -B option). The -b option specifies instead that [4mn[0m 484170256Sdelphij kilobytes of buffer space should be used for each file. If [4mn[24m is 485191930Sdelphij -1, buffer space is unlimited; that is, the entire file can be 486173932Sdelphij read into memory. 48763128Sps 48860786Sps -B or --auto-buffers 489161475Sdelphij By default, when data is read from a pipe, buffers are allocated 490161475Sdelphij automatically as needed. If a large amount of data is read from 491191930Sdelphij the pipe, this can cause a large amount of memory to be allo- 492221715Sdelphij cated. The -B option disables this automatic allocation of buf- 493221715Sdelphij fers for pipes, so that only 64K (or the amount of space speci- 494221715Sdelphij fied by the -b option) is used for the pipe. Warning: use of -B 495221715Sdelphij can result in erroneous display, since only the most recently 496221715Sdelphij viewed part of the piped data is kept in memory; any earlier 497221715Sdelphij data is lost. 49860786Sps 49960786Sps -c or --clear-screen 500191930Sdelphij Causes full screen repaints to be painted from the top line 501191930Sdelphij down. By default, full screen repaints are done by scrolling 502161475Sdelphij from the bottom of the screen. 50360786Sps 50460786Sps -C or --CLEAR-SCREEN 505170256Sdelphij Same as -c, for compatibility with older versions of [4mless.[0m 50660786Sps 50760786Sps -d or --dumb 508161475Sdelphij The -d option suppresses the error message normally displayed if 509191930Sdelphij the terminal is dumb; that is, lacks some important capability, 510161475Sdelphij such as the ability to clear the screen or scroll backward. The 511191930Sdelphij -d option does not otherwise change the behavior of [4mless[24m on a 512128345Stjr dumb terminal. 51360786Sps 514170256Sdelphij -D[1mx[4m[22mcolor[24m or --color=[1mx[4m[22mcolor[0m 515170256Sdelphij [MS-DOS only] Sets the color of the text displayed. [1mx [22mis a sin- 516191930Sdelphij gle character which selects the type of text whose color is 517191930Sdelphij being set: n=normal, s=standout, d=bold, u=underlined, k=blink. 518191930Sdelphij [4mcolor[24m is a pair of numbers separated by a period. The first 519191930Sdelphij number selects the foreground color and the second selects the 520191930Sdelphij background color of the text. A single number [4mN[24m is the same as 521191930Sdelphij [4mN.M[24m, where [4mM[24m is the normal background color. 52260786Sps 523191930Sdelphij 524128345Stjr -e or --quit-at-eof 525191930Sdelphij Causes [4mless[24m to automatically exit the second time it reaches 526191930Sdelphij end-of-file. By default, the only way to exit [4mless[24m is via the 527161475Sdelphij "q" command. 52863128Sps 52989019Sps -E or --QUIT-AT-EOF 530170256Sdelphij Causes [4mless[24m to automatically exit the first time it reaches end- 531161475Sdelphij of-file. 53260786Sps 53363128Sps -f or --force 534161475Sdelphij Forces non-regular files to be opened. (A non-regular file is a 535191930Sdelphij directory or a device special file.) Also suppresses the warn- 536170256Sdelphij ing message when a binary file is opened. By default, [4mless[24m will 537170256Sdelphij refuse to open non-regular files. Note that some operating sys- 538170256Sdelphij tems will not allow directories to be read, even if -f is set. 53960786Sps 54060786Sps -F or --quit-if-one-screen 541170256Sdelphij Causes [4mless[24m to automatically exit if the entire file can be dis- 542161475Sdelphij played on the first screen. 54360786Sps 54460786Sps -g or --hilite-search 545191930Sdelphij Normally, [4mless[24m will highlight ALL strings which match the last 546191930Sdelphij search command. The -g option changes this behavior to high- 547191930Sdelphij light only the particular string which was found by the last 548170256Sdelphij search command. This can cause [4mless[24m to run somewhat faster than 549161475Sdelphij the default. 55060786Sps 55160786Sps -G or --HILITE-SEARCH 552191930Sdelphij The -G option suppresses all highlighting of strings found by 553161475Sdelphij search commands. 55460786Sps 555170256Sdelphij -h[4mn[24m or --max-back-scroll=[4mn[0m 556191930Sdelphij Specifies a maximum number of lines to scroll backward. If it 557170256Sdelphij is necessary to scroll backward more than [4mn[24m lines, the screen is 558161475Sdelphij repainted in a forward direction instead. (If the terminal does 559161475Sdelphij not have the ability to scroll backward, -h0 is implied.) 56060786Sps 56160786Sps -i or --ignore-case 562161475Sdelphij Causes searches to ignore case; that is, uppercase and lowercase 563191930Sdelphij are considered identical. This option is ignored if any upper- 564191930Sdelphij case letters appear in the search pattern; in other words, if a 565191930Sdelphij pattern contains uppercase letters, then that search does not 566161475Sdelphij ignore case. 56760786Sps 56860786Sps -I or --IGNORE-CASE 569191930Sdelphij Like -i, but searches ignore case even if the pattern contains 570161475Sdelphij uppercase letters. 57160786Sps 572170256Sdelphij -j[4mn[24m or --jump-target=[4mn[0m 573191930Sdelphij Specifies a line on the screen where the "target" line is to be 574191930Sdelphij positioned. The target line is the line specified by any com- 575191930Sdelphij mand to search for a pattern, jump to a line number, jump to a 576173932Sdelphij file percentage or jump to a tag. The screen line may be speci- 577191930Sdelphij fied by a number: the top line on the screen is 1, the next is 578173932Sdelphij 2, and so on. The number may be negative to specify a line rel- 579173932Sdelphij ative to the bottom of the screen: the bottom line on the screen 580191930Sdelphij is -1, the second to the bottom is -2, and so on. Alternately, 581191930Sdelphij the screen line may be specified as a fraction of the height of 582191930Sdelphij the screen, starting with a decimal point: .5 is in the middle 583191930Sdelphij of the screen, .3 is three tenths down from the first line, and 584191930Sdelphij so on. If the line is specified as a fraction, the actual line 585191930Sdelphij number is recalculated if the terminal window is resized, so 586191930Sdelphij that the target line remains at the specified fraction of the 587191930Sdelphij screen height. If any form of the -j option is used, forward 588191930Sdelphij searches begin at the line immediately after the target line, 589221715Sdelphij and backward searches begin at the target line, unless changed 590221715Sdelphij by -a or -A. For example, if "-j4" is used, the target line is 591221715Sdelphij the fourth line on the screen, so forward searches begin at the 592221715Sdelphij fifth line on the screen. 59360786Sps 59463128Sps -J or --status-column 595221715Sdelphij Displays a status column at the left edge of the screen. The 596221715Sdelphij status column shows the lines that matched the current search. 597221715Sdelphij The status column is also used if the -w or -W option is in 598161475Sdelphij effect. 59963128Sps 600170256Sdelphij -k[4mfilename[24m or --lesskey-file=[4mfilename[0m 601221715Sdelphij Causes [4mless[24m to open and interpret the named file as a [4mlesskey[0m 602161475Sdelphij (1) file. Multiple -k options may be specified. If the LESSKEY 603221715Sdelphij or LESSKEY_SYSTEM environment variable is set, or if a lesskey 604161475Sdelphij file is found in a standard place (see KEY BINDINGS), it is also 605170256Sdelphij used as a [4mlesskey[24m file. 60660786Sps 607161475Sdelphij -K or --quit-on-intr 608221715Sdelphij Causes [4mless[24m to exit immediately (with status 2) when an inter- 609221715Sdelphij rupt character (usually ^C) is typed. Normally, an interrupt 610221715Sdelphij character causes [4mless[24m to stop whatever it is doing and return to 611221715Sdelphij its command prompt. Note that use of this option makes it 612221715Sdelphij impossible to return to the command prompt from the "F" command. 613161475Sdelphij 614128345Stjr -L or --no-lessopen 615221715Sdelphij Ignore the LESSOPEN environment variable (see the INPUT PRE- 616221715Sdelphij PROCESSOR section below). This option can be set from within 617221715Sdelphij [4mless[24m, but it will apply only to files opened subsequently, not 618191930Sdelphij to the file which is currently open. 619128345Stjr 62060786Sps -m or --long-prompt 621221715Sdelphij Causes [4mless[24m to prompt verbosely (like [4mmore[24m), with the percent 622170256Sdelphij into the file. By default, [4mless[24m prompts with a colon. 62360786Sps 62460786Sps -M or --LONG-PROMPT 625170256Sdelphij Causes [4mless[24m to prompt even more verbosely than [4mmore.[0m 62660786Sps 62760786Sps -n or --line-numbers 628221715Sdelphij Suppresses line numbers. The default (to use line numbers) may 629221715Sdelphij cause [4mless[24m to run more slowly in some cases, especially with a 630221715Sdelphij very large input file. Suppressing line numbers with the -n 631221715Sdelphij option will avoid this problem. Using line numbers means: the 632161475Sdelphij line number will be displayed in the verbose prompt and in the = 633221715Sdelphij command, and the v command will pass the current line number to 634221715Sdelphij the editor (see also the discussion of LESSEDIT in PROMPTS 635161475Sdelphij below). 63660786Sps 637128345Stjr -N or --LINE-NUMBERS 638221715Sdelphij Causes a line number to be displayed at the beginning of each 639161475Sdelphij line in the display. 64060786Sps 641170256Sdelphij -o[4mfilename[24m or --log-file=[4mfilename[0m 642221715Sdelphij Causes [4mless[24m to copy its input to the named file as it is being 643161475Sdelphij viewed. This applies only when the input file is a pipe, not an 644221715Sdelphij ordinary file. If the file already exists, [4mless[24m will ask for 645161475Sdelphij confirmation before overwriting it. 64660786Sps 647170256Sdelphij -O[4mfilename[24m or --LOG-FILE=[4mfilename[0m 648161475Sdelphij The -O option is like -o, but it will overwrite an existing file 649161475Sdelphij without asking for confirmation. 65060786Sps 651221715Sdelphij If no log file has been specified, the -o and -O options can be 652221715Sdelphij used from within [4mless[24m to specify a log file. Without a file 653161475Sdelphij name, they will simply report the name of the log file. The "s" 654170256Sdelphij command is equivalent to specifying -o from within [4mless.[0m 65563128Sps 656170256Sdelphij -p[4mpattern[24m or --pattern=[4mpattern[0m 657221715Sdelphij The -p option on the command line is equivalent to specifying 658221715Sdelphij +/[4mpattern[24m; that is, it tells [4mless[24m to start at the first occur- 659170256Sdelphij rence of [4mpattern[24m in the file. 66063128Sps 661170256Sdelphij -P[4mprompt[24m or --prompt=[4mprompt[0m 662221715Sdelphij Provides a way to tailor the three prompt styles to your own 663161475Sdelphij preference. This option would normally be put in the LESS envi- 664170256Sdelphij ronment variable, rather than being typed in with each [4mless[24m com- 665161475Sdelphij mand. Such an option must either be the last option in the LESS 666221715Sdelphij variable, or be terminated by a dollar sign. -Ps followed by a 667221715Sdelphij string changes the default (short) prompt to that string. -Pm 668221715Sdelphij changes the medium (-m) prompt. -PM changes the long (-M) 669221715Sdelphij prompt. -Ph changes the prompt for the help screen. -P= 670221715Sdelphij changes the message printed by the = command. -Pw changes the 671221715Sdelphij message printed while waiting for data (in the F command). All 672221715Sdelphij prompt strings consist of a sequence of letters and special 673221715Sdelphij escape sequences. See the section on PROMPTS for more details. 67460786Sps 67560786Sps -q or --quiet or --silent 676191930Sdelphij Causes moderately "quiet" operation: the terminal bell is not 677161475Sdelphij rung if an attempt is made to scroll past the end of the file or 678161475Sdelphij before the beginning of the file. If the terminal has a "visual 679191930Sdelphij bell", it is used instead. The bell will be rung on certain 680191930Sdelphij other errors, such as typing an invalid character. The default 681161475Sdelphij is to ring the terminal bell in all such cases. 68260786Sps 683128345Stjr -Q or --QUIET or --SILENT 684191930Sdelphij Causes totally "quiet" operation: the terminal bell is never 685161475Sdelphij rung. 686128345Stjr 687128345Stjr -r or --raw-control-chars 688161475Sdelphij Causes "raw" control characters to be displayed. The default is 689191930Sdelphij to display control characters using the caret notation; for 690161475Sdelphij example, a control-A (octal 001) is displayed as "^A". Warning: 691170256Sdelphij when the -r option is used, [4mless[24m cannot keep track of the actual 692191930Sdelphij appearance of the screen (since this depends on how the screen 693161475Sdelphij responds to each type of control character). Thus, various dis- 694191930Sdelphij play problems may result, such as long lines being split in the 695161475Sdelphij wrong place. 69660786Sps 69763128Sps -R or --RAW-CONTROL-CHARS 698191930Sdelphij Like -r, but only ANSI "color" escape sequences are output in 699161475Sdelphij "raw" form. Unlike -r, the screen appearance is maintained cor- 700161475Sdelphij rectly in most cases. ANSI "color" escape sequences are 701161475Sdelphij sequences of the form: 70263128Sps 70363128Sps ESC [ ... m 70463128Sps 705191930Sdelphij where the "..." is zero or more color specification characters 706191930Sdelphij For the purpose of keeping track of screen appearance, ANSI 707191930Sdelphij color escape sequences are assumed to not move the cursor. You 708191930Sdelphij can make [4mless[24m think that characters other than "m" can end ANSI 709191930Sdelphij color escape sequences by setting the environment variable 710161475Sdelphij LESSANSIENDCHARS to the list of characters which can end a color 711191930Sdelphij escape sequence. And you can make [4mless[24m think that characters 712191930Sdelphij other than the standard ones may appear between the ESC and the 713191930Sdelphij m by setting the environment variable LESSANSIMIDCHARS to the 714161475Sdelphij list of characters which can appear. 71560786Sps 71660786Sps -s or --squeeze-blank-lines 717191930Sdelphij Causes consecutive blank lines to be squeezed into a single 718170256Sdelphij blank line. This is useful when viewing [4mnroff[24m output. 71960786Sps 72060786Sps -S or --chop-long-lines 721240121Sdelphij Causes lines longer than the screen width to be chopped (trun- 722240121Sdelphij cated) rather than wrapped. That is, the portion of a long line 723240121Sdelphij that does not fit in the screen width is not shown. The default 724240121Sdelphij is to wrap long lines; that is, display the remainder on the 725240121Sdelphij next line. 72660786Sps 727170256Sdelphij -t[4mtag[24m or --tag=[4mtag[0m 728161475Sdelphij The -t option, followed immediately by a TAG, will edit the file 729240121Sdelphij containing that tag. For this to work, tag information must be 730240121Sdelphij available; for example, there may be a file in the current 731170256Sdelphij directory called "tags", which was previously built by [4mctags[24m (1) 732161475Sdelphij or an equivalent command. If the environment variable LESSGLOB- 733240121Sdelphij ALTAGS is set, it is taken to be the name of a command compati- 734240121Sdelphij ble with [4mglobal[24m (1), and that command is executed to find the 735161475Sdelphij tag. (See http://www.gnu.org/software/global/global.html). The 736240121Sdelphij -t option may also be specified from within [4mless[24m (using the - 737240121Sdelphij command) as a way of examining a new file. The command ":t" is 738170256Sdelphij equivalent to specifying -t from within [4mless.[0m 73960786Sps 740170256Sdelphij -T[4mtagsfile[24m or --tag-file=[4mtagsfile[0m 74189019Sps Specifies a tags file to be used instead of "tags". 74260786Sps 74389019Sps -u or --underline-special 744240121Sdelphij Causes backspaces and carriage returns to be treated as print- 745240121Sdelphij able characters; that is, they are sent to the terminal when 746161475Sdelphij they appear in the input. 74760786Sps 74889019Sps -U or --UNDERLINE-SPECIAL 749240121Sdelphij Causes backspaces, tabs and carriage returns to be treated as 750240121Sdelphij control characters; that is, they are handled as specified by 751161475Sdelphij the -r option. 75260786Sps 753240121Sdelphij By default, if neither -u nor -U is given, backspaces which 754240121Sdelphij appear adjacent to an underscore character are treated spe- 755240121Sdelphij cially: the underlined text is displayed using the terminal's 756240121Sdelphij hardware underlining capability. Also, backspaces which appear 757240121Sdelphij between two identical characters are treated specially: the 758240121Sdelphij overstruck text is printed using the terminal's hardware bold- 759240121Sdelphij face capability. Other backspaces are deleted, along with the 760161475Sdelphij preceding character. Carriage returns immediately followed by a 761240121Sdelphij newline are deleted. Other carriage returns are handled as 762240121Sdelphij specified by the -r option. Text which is overstruck or under- 763161475Sdelphij lined can be searched for if neither -u nor -U is in effect. 76460786Sps 76560786Sps -V or --version 766170256Sdelphij Displays the version number of [4mless.[0m 76760786Sps 76860786Sps -w or --hilite-unread 769240121Sdelphij Temporarily highlights the first "new" line after a forward 770161475Sdelphij movement of a full page. The first "new" line is the line imme- 771240121Sdelphij diately following the line previously at the bottom of the 772161475Sdelphij screen. Also highlights the target line after a g or p command. 773240121Sdelphij The highlight is removed at the next command which causes move- 774240121Sdelphij ment. The entire line is highlighted, unless the -J option is 775221715Sdelphij in effect, in which case only the status column is highlighted. 77660786Sps 77760786Sps -W or --HILITE-UNREAD 778161475Sdelphij Like -w, but temporarily highlights the first new line after any 779161475Sdelphij forward movement command larger than one line. 78060786Sps 781170256Sdelphij -x[4mn[24m,... or --tabs=[4mn[24m,... 782240121Sdelphij Sets tab stops. If only one [4mn[24m is specified, tab stops are set 783240121Sdelphij at multiples of [4mn[24m. If multiple values separated by commas are 784240121Sdelphij specified, tab stops are set at those positions, and then con- 785240121Sdelphij tinue with the same spacing as the last two. For example, 786240121Sdelphij [4m-x9,17[24m will set tabs at positions 9, 17, 25, 33, etc. The 787170256Sdelphij default for [4mn[24m is 8. 78860786Sps 78989019Sps -X or --no-init 790161475Sdelphij Disables sending the termcap initialization and deinitialization 791240121Sdelphij strings to the terminal. This is sometimes desirable if the 792240121Sdelphij deinitialization string does something unnecessary, like clear- 793161475Sdelphij ing the screen. 79460786Sps 795170256Sdelphij -y[4mn[24m or --max-forw-scroll=[4mn[0m 796161475Sdelphij Specifies a maximum number of lines to scroll forward. If it is 797240121Sdelphij necessary to scroll forward more than [4mn[24m lines, the screen is 798240121Sdelphij repainted instead. The -c or -C option may be used to repaint 799240121Sdelphij from the top of the screen if desired. By default, any forward 80089019Sps movement causes scrolling. 80160786Sps 802170256Sdelphij -[z][4mn[24m or --window=[4mn[0m 803240121Sdelphij Changes the default scrolling window size to [4mn[24m lines. The 804161475Sdelphij default is one screenful. The z and w commands can also be used 805240121Sdelphij to change the window size. The "z" may be omitted for compati- 806170256Sdelphij bility with some versions of [4mmore.[24m If the number [4mn[24m is negative, 807240121Sdelphij it indicates [4mn[24m lines less than the current screen size. For 808170256Sdelphij example, if the screen is 24 lines, [4m-z-4[24m sets the scrolling win- 809240121Sdelphij dow to 20 lines. If the screen is resized to 40 lines, the 810170256Sdelphij scrolling window automatically changes to 36 lines. 81163128Sps 812170256Sdelphij -[4m"cc[24m or --quotes=[4mcc[0m 813240121Sdelphij Changes the filename quoting character. This may be necessary 814240121Sdelphij if you are trying to name a file which contains both spaces and 815240121Sdelphij quote characters. Followed by a single character, this changes 816240121Sdelphij the quote character to that character. Filenames containing a 817161475Sdelphij space should then be surrounded by that character rather than by 818240121Sdelphij double quotes. Followed by two characters, changes the open 819240121Sdelphij quote to the first character, and the close quote to the second 820161475Sdelphij character. Filenames containing a space should then be preceded 821240121Sdelphij by the open quote character and followed by the close quote 822240121Sdelphij character. Note that even after the quote characters are 823240121Sdelphij changed, this option remains -" (a dash followed by a double 824161475Sdelphij quote). 82560786Sps 826128345Stjr -~ or --tilde 827161475Sdelphij Normally lines after end of file are displayed as a single tilde 828161475Sdelphij (~). This option causes lines after end of file to be displayed 829161475Sdelphij as blank lines. 83060786Sps 83163128Sps -# or --shift 832161475Sdelphij Specifies the default number of positions to scroll horizontally 833240121Sdelphij in the RIGHTARROW and LEFTARROW commands. If the number speci- 834240121Sdelphij fied is zero, it sets the default number of positions to one 835195941Sdelphij half of the screen width. Alternately, the number may be speci- 836240121Sdelphij fied as a fraction of the width of the screen, starting with a 837240121Sdelphij decimal point: .5 is half of the screen width, .3 is three 838240121Sdelphij tenths of the screen width, and so on. If the number is speci- 839240121Sdelphij fied as a fraction, the actual number of scroll positions is 840240121Sdelphij recalculated if the terminal window is resized, so that the 841240121Sdelphij actual scroll remains at the specified fraction of the screen 842195941Sdelphij width. 84363128Sps 844173682Sdelphij --follow-name 845240121Sdelphij Normally, if the input file is renamed while an F command is 846240121Sdelphij executing, [4mless[24m will continue to display the contents of the 847240121Sdelphij original file despite its name change. If --follow-name is 848173682Sdelphij specified, during an F command [4mless[24m will periodically attempt to 849173682Sdelphij reopen the file by name. If the reopen succeeds and the file is 850240121Sdelphij a different file from the original (which means that a new file 851240121Sdelphij has been created with the same name as the original (now 852173682Sdelphij renamed) file), [4mless[24m will display the contents of that new file. 853173682Sdelphij 854251154Sdelphij --no-keypad 855251154Sdelphij Disables sending the keypad initialization and deinitialization 856251154Sdelphij strings to the terminal. This is sometimes useful if the keypad 857251154Sdelphij strings make the numeric keypad behave in an undesirable manner. 858251154Sdelphij 859251154Sdelphij --use-backslash 860251154Sdelphij This option changes the interpretations of options which follow 861251154Sdelphij this one. After the --use-backslash option, any backslash in an 862251154Sdelphij option string is removed and the following character is taken 863251154Sdelphij literally. This allows a dollar sign to be included in option 864251154Sdelphij strings. 865251154Sdelphij 866240121Sdelphij -- A command line argument of "--" marks the end of option argu- 867240121Sdelphij ments. Any arguments following this are interpreted as file- 868161475Sdelphij names. This can be useful when viewing a file whose name begins 869161475Sdelphij with a "-" or "+". 87060786Sps 871240121Sdelphij + If a command line option begins with [1m+[22m, the remainder of that 872240121Sdelphij option is taken to be an initial command to [4mless.[24m For example, 873240121Sdelphij +G tells [4mless[24m to start at the end of the file rather than the 874240121Sdelphij beginning, and +/xyz tells it to start at the first occurrence 875240121Sdelphij of "xyz" in the file. As a special case, +<number> acts like 876161475Sdelphij +<number>g; that is, it starts the display at the specified line 877240121Sdelphij number (however, see the caveat under the "g" command above). 878240121Sdelphij If the option starts with ++, the initial command applies to 879240121Sdelphij every file being viewed, not just the first one. The + command 880161475Sdelphij described previously may also be used to set (or change) an ini- 881161475Sdelphij tial command for every file. 88260786Sps 88360786Sps 884170256Sdelphij[1mLINE EDITING[0m 885240121Sdelphij When entering command line at the bottom of the screen (for example, a 886170256Sdelphij filename for the :e command, or the pattern for a search command), cer- 887240121Sdelphij tain keys can be used to manipulate the command line. Most commands 888240121Sdelphij have an alternate form in [ brackets ] which can be used if a key does 889240121Sdelphij not exist on a particular keyboard. (Note that the forms beginning 890240121Sdelphij with ESC do not work in some MS-DOS and Windows systems because ESC is 891240121Sdelphij the line erase character.) Any of these special keys may be entered 892240121Sdelphij literally by preceding it with the "literal" character, either ^V or 893240121Sdelphij ^A. A backslash itself may also be entered literally by entering two 894191930Sdelphij backslashes. 89560786Sps 89663128Sps LEFTARROW [ ESC-h ] 89763128Sps Move the cursor one space to the left. 89860786Sps 899128345Stjr RIGHTARROW [ ESC-l ] 900128345Stjr Move the cursor one space to the right. 90189019Sps 902128345Stjr ^LEFTARROW [ ESC-b or ESC-LEFTARROW ] 903240121Sdelphij (That is, CONTROL and LEFTARROW simultaneously.) Move the cur- 904161475Sdelphij sor one word to the left. 90589019Sps 906128345Stjr ^RIGHTARROW [ ESC-w or ESC-RIGHTARROW ] 907161475Sdelphij (That is, CONTROL and RIGHTARROW simultaneously.) Move the cur- 908161475Sdelphij sor one word to the right. 90960786Sps 91060786Sps HOME [ ESC-0 ] 91160786Sps Move the cursor to the beginning of the line. 91260786Sps 91360786Sps END [ ESC-$ ] 91460786Sps Move the cursor to the end of the line. 91560786Sps 91660786Sps BACKSPACE 917240121Sdelphij Delete the character to the left of the cursor, or cancel the 918161475Sdelphij command if the command line is empty. 91960786Sps 92060786Sps DELETE or [ ESC-x ] 92160786Sps Delete the character under the cursor. 92260786Sps 92360786Sps ^BACKSPACE [ ESC-BACKSPACE ] 924240121Sdelphij (That is, CONTROL and BACKSPACE simultaneously.) Delete the 925161475Sdelphij word to the left of the cursor. 92660786Sps 92760786Sps ^DELETE [ ESC-X or ESC-DELETE ] 928240121Sdelphij (That is, CONTROL and DELETE simultaneously.) Delete the word 929161475Sdelphij under the cursor. 93060786Sps 93163128Sps UPARROW [ ESC-k ] 932240121Sdelphij Retrieve the previous command line. If you first enter some 933240121Sdelphij text and then press UPARROW, it will retrieve the previous com- 934240121Sdelphij mand which begins with that text. 93560786Sps 93663128Sps DOWNARROW [ ESC-j ] 937240121Sdelphij Retrieve the next command line. If you first enter some text 938240121Sdelphij and then press DOWNARROW, it will retrieve the next command 939240121Sdelphij which begins with that text. 94060786Sps 941240121Sdelphij TAB Complete the partial filename to the left of the cursor. If it 942240121Sdelphij matches more than one filename, the first match is entered into 943240121Sdelphij the command line. Repeated TABs will cycle thru the other 944161475Sdelphij matching filenames. If the completed filename is a directory, a 945240121Sdelphij "/" is appended to the filename. (On MS-DOS systems, a "\" is 946240121Sdelphij appended.) The environment variable LESSSEPARATOR can be used 947221715Sdelphij to specify a different character to append to a directory name. 94860786Sps 94963128Sps BACKTAB [ ESC-TAB ] 950161475Sdelphij Like, TAB, but cycles in the reverse direction thru the matching 951161475Sdelphij filenames. 95260786Sps 953240121Sdelphij ^L Complete the partial filename to the left of the cursor. If it 954161475Sdelphij matches more than one filename, all matches are entered into the 955161475Sdelphij command line (if they fit). 95660786Sps 957128345Stjr ^U (Unix and OS/2) or ESC (MS-DOS) 958240121Sdelphij Delete the entire command line, or cancel the command if the 959161475Sdelphij command line is empty. If you have changed your line-kill char- 960161475Sdelphij acter in Unix to something other than ^U, that character is used 961161475Sdelphij instead of ^U. 962128345Stjr 963221715Sdelphij ^G Delete the entire command line and return to the main prompt. 964128345Stjr 965221715Sdelphij 966170256Sdelphij[1mKEY BINDINGS[0m 967240121Sdelphij You may define your own [4mless[24m commands by using the program [4mlesskey[24m (1) 968240121Sdelphij to create a lesskey file. This file specifies a set of command keys 969240121Sdelphij and an action associated with each key. You may also use [4mlesskey[24m to 970161475Sdelphij change the line-editing keys (see LINE EDITING), and to set environment 971240121Sdelphij variables. If the environment variable LESSKEY is set, [4mless[24m uses that 972240121Sdelphij as the name of the lesskey file. Otherwise, [4mless[24m looks in a standard 973240121Sdelphij place for the lesskey file: On Unix systems, [4mless[24m looks for a lesskey 974240121Sdelphij file called "$HOME/.less". On MS-DOS and Windows systems, [4mless[24m looks 975240121Sdelphij for a lesskey file called "$HOME/_less", and if it is not found there, 976161475Sdelphij then looks for a lesskey file called "_less" in any directory specified 977240121Sdelphij in the PATH environment variable. On OS/2 systems, [4mless[24m looks for a 978240121Sdelphij lesskey file called "$HOME/less.ini", and if it is not found, then 979240121Sdelphij looks for a lesskey file called "less.ini" in any directory specified 980161475Sdelphij in the INIT environment variable, and if it not found there, then looks 981240121Sdelphij for a lesskey file called "less.ini" in any directory specified in the 982240121Sdelphij PATH environment variable. See the [4mlesskey[24m manual page for more 983161475Sdelphij details. 98460786Sps 985240121Sdelphij A system-wide lesskey file may also be set up to provide key bindings. 986161475Sdelphij If a key is defined in both a local lesskey file and in the system-wide 987240121Sdelphij file, key bindings in the local file take precedence over those in the 988240121Sdelphij system-wide file. If the environment variable LESSKEY_SYSTEM is set, 989170256Sdelphij [4mless[24m uses that as the name of the system-wide lesskey file. Otherwise, 990240121Sdelphij [4mless[24m looks in a standard place for the system-wide lesskey file: On 991240121Sdelphij Unix systems, the system-wide lesskey file is /usr/local/etc/sysless. 992240121Sdelphij (However, if [4mless[24m was built with a different sysconf directory than 993161475Sdelphij /usr/local/etc, that directory is where the sysless file is found.) On 994240121Sdelphij MS-DOS and Windows systems, the system-wide lesskey file is c:\_sys- 995161475Sdelphij less. On OS/2 systems, the system-wide lesskey file is c:\sysless.ini. 99660786Sps 99760786Sps 998170256Sdelphij[1mINPUT PREPROCESSOR[0m 999240121Sdelphij You may define an "input preprocessor" for [4mless.[24m Before [4mless[24m opens a 1000161475Sdelphij file, it first gives your input preprocessor a chance to modify the way 1001240121Sdelphij the contents of the file are displayed. An input preprocessor is sim- 1002240121Sdelphij ply an executable program (or shell script), which writes the contents 1003161475Sdelphij of the file to a different file, called the replacement file. The con- 1004240121Sdelphij tents of the replacement file are then displayed in place of the con- 1005240121Sdelphij tents of the original file. However, it will appear to the user as if 1006240121Sdelphij the original file is opened; that is, [4mless[24m will display the original 1007161475Sdelphij filename as the name of the current file. 100860786Sps 1009240121Sdelphij An input preprocessor receives one command line argument, the original 1010240121Sdelphij filename, as entered by the user. It should create the replacement 1011240121Sdelphij file, and when finished, print the name of the replacement file to its 1012240121Sdelphij standard output. If the input preprocessor does not output a replace- 1013240121Sdelphij ment filename, [4mless[24m uses the original file, as normal. The input pre- 1014240121Sdelphij processor is not called when viewing standard input. To set up an 1015240121Sdelphij input preprocessor, set the LESSOPEN environment variable to a command 1016240121Sdelphij line which will invoke your input preprocessor. This command line 1017240121Sdelphij should include one occurrence of the string "%s", which will be 1018240121Sdelphij replaced by the filename when the input preprocessor command is 101989019Sps invoked. 102089019Sps 1021170256Sdelphij When [4mless[24m closes a file opened in such a way, it will call another pro- 1022240121Sdelphij gram, called the input postprocessor, which may perform any desired 1023240121Sdelphij clean-up action (such as deleting the replacement file created by 1024161475Sdelphij LESSOPEN). This program receives two command line arguments, the orig- 1025240121Sdelphij inal filename as entered by the user, and the name of the replacement 1026240121Sdelphij file. To set up an input postprocessor, set the LESSCLOSE environment 1027240121Sdelphij variable to a command line which will invoke your input postprocessor. 1028240121Sdelphij It may include two occurrences of the string "%s"; the first is 1029240121Sdelphij replaced with the original name of the file and the second with the 1030161475Sdelphij name of the replacement file, which was output by LESSOPEN. 103160786Sps 1032240121Sdelphij For example, on many Unix systems, these two scripts will allow you to 1033170256Sdelphij keep files in compressed format, but still let [4mless[24m view them directly: 103460786Sps 103560786Sps lessopen.sh: 103660786Sps #! /bin/sh 103760786Sps case "$1" in 1038161475Sdelphij *.Z) uncompress - 103960786Sps if [ -s /tmp/less.$$ ]; then 104060786Sps echo /tmp/less.$$ 104160786Sps else 104260786Sps rm -f /tmp/less.$$ 104360786Sps fi 104460786Sps ;; 104560786Sps esac 104660786Sps 104760786Sps lessclose.sh: 104860786Sps #! /bin/sh 104960786Sps rm $2 105060786Sps 1051240121Sdelphij To use these scripts, put them both where they can be executed and set 1052161475Sdelphij LESSOPEN="lessopen.sh %s", and LESSCLOSE="lessclose.sh %s %s". More 1053240121Sdelphij complex LESSOPEN and LESSCLOSE scripts may be written to accept other 1054161475Sdelphij types of compressed files, and so on. 105560786Sps 1056240121Sdelphij It is also possible to set up an input preprocessor to pipe the file 1057240121Sdelphij data directly to [4mless,[24m rather than putting the data into a replacement 1058161475Sdelphij file. This avoids the need to decompress the entire file before start- 1059161475Sdelphij ing to view it. An input preprocessor that works this way is called an 1060240121Sdelphij input pipe. An input pipe, instead of writing the name of a replace- 1061240121Sdelphij ment file on its standard output, writes the entire contents of the 1062240121Sdelphij replacement file on its standard output. If the input pipe does not 1063240121Sdelphij write any characters on its standard output, then there is no replace- 1064240121Sdelphij ment file and [4mless[24m uses the original file, as normal. To use an input 1065240121Sdelphij pipe, make the first character in the LESSOPEN environment variable a 1066240121Sdelphij vertical bar (|) to signify that the input preprocessor is an input 1067161475Sdelphij pipe. 106889019Sps 1069240121Sdelphij For example, on many Unix systems, this script will work like the pre- 1070161475Sdelphij vious example scripts: 107189019Sps 107260786Sps lesspipe.sh: 107360786Sps #! /bin/sh 107460786Sps case "$1" in 107560786Sps *.Z) uncompress -c $1 2>/dev/null 1076240121Sdelphij *) exit 1 107760786Sps ;; 107860786Sps esac 1079240121Sdelphij exit $? 108060786Sps 1081161475Sdelphij To use this script, put it where it can be executed and set 1082240121Sdelphij LESSOPEN="|lesspipe.sh %s". 108360786Sps 1084240121Sdelphij Note that a preprocessor cannot output an empty file, since that is 1085240121Sdelphij interpreted as meaning there is no replacement, and the original file 1086240121Sdelphij is used. To avoid this, if LESSOPEN starts with two vertical bars, the 1087240121Sdelphij exit status of the script becomes meaningful. If the exit status is 1088240121Sdelphij zero, the output is considered to be replacement text, even if it 1089240121Sdelphij empty. If the exit status is nonzero, any output is ignored and the 1090240121Sdelphij original file is used. For compatibility with previous versions of 1091240121Sdelphij [4mless,[24m if LESSOPEN starts with only one vertical bar, the exit status of 1092240121Sdelphij the preprocessor is ignored. 1093240121Sdelphij 1094240121Sdelphij When an input pipe is used, a LESSCLOSE postprocessor can be used, but 1095240121Sdelphij it is usually not necessary since there is no replacement file to clean 1096240121Sdelphij up. In this case, the replacement file name passed to the LESSCLOSE 1097240121Sdelphij postprocessor is "-". 1098240121Sdelphij 1099240121Sdelphij For compatibility with previous versions of [4mless,[24m the input preproces- 1100195941Sdelphij sor or pipe is not used if [4mless[24m is viewing standard input. However, if 1101240121Sdelphij the first character of LESSOPEN is a dash (-), the input preprocessor 1102240121Sdelphij is used on standard input as well as other files. In this case, the 1103240121Sdelphij dash is not considered to be part of the preprocessor command. If 1104195941Sdelphij standard input is being viewed, the input preprocessor is passed a file 1105240121Sdelphij name consisting of a single dash. Similarly, if the first two charac- 1106240121Sdelphij ters of LESSOPEN are vertical bar and dash (|-) or two vertical bars 1107240121Sdelphij and a dash (||-), the input pipe is used on standard input as well as 1108240121Sdelphij other files. Again, in this case the dash is not considered to be part 1109240121Sdelphij of the input pipe command. 111060786Sps 1111191930Sdelphij 1112170256Sdelphij[1mNATIONAL CHARACTER SETS[0m 111360786Sps There are three types of characters in the input file: 111460786Sps 111560786Sps normal characters 111660786Sps can be displayed directly to the screen. 111760786Sps 111860786Sps control characters 1119195941Sdelphij should not be displayed directly, but are expected to be found 1120161475Sdelphij in ordinary text files (such as backspace and tab). 112160786Sps 112260786Sps binary characters 1123195941Sdelphij should not be displayed directly and are not expected to be 1124161475Sdelphij found in text files. 112560786Sps 1126161475Sdelphij A "character set" is simply a description of which characters are to be 1127195941Sdelphij considered normal, control, and binary. The LESSCHARSET environment 1128195941Sdelphij variable may be used to select a character set. Possible values for 1129161475Sdelphij LESSCHARSET are: 113060786Sps 1131195941Sdelphij ascii BS, TAB, NL, CR, and formfeed are control characters, all chars 1132195941Sdelphij with values between 32 and 126 are normal, and all others are 1133161475Sdelphij binary. 113460786Sps 113589019Sps iso8859 1136195941Sdelphij Selects an ISO 8859 character set. This is the same as ASCII, 1137195941Sdelphij except characters between 160 and 255 are treated as normal 1138161475Sdelphij characters. 113960786Sps 114089019Sps latin1 Same as iso8859. 114160786Sps 114289019Sps latin9 Same as iso8859. 114360786Sps 114489019Sps dos Selects a character set appropriate for MS-DOS. 114560786Sps 114689019Sps ebcdic Selects an EBCDIC character set. 114760786Sps 114889019Sps IBM-1047 1149195941Sdelphij Selects an EBCDIC character set used by OS/390 Unix Services. 1150195941Sdelphij This is the EBCDIC analogue of latin1. You get similar results 1151161475Sdelphij by setting either LESSCHARSET=IBM-1047 or LC_CTYPE=en_US in your 1152161475Sdelphij environment. 115360786Sps 115489019Sps koi8-r Selects a Russian character set. 115560786Sps 1156161475Sdelphij next Selects a character set appropriate for NeXT computers. 115789019Sps 1158195941Sdelphij utf-8 Selects the UTF-8 encoding of the ISO 10646 character set. 1159195941Sdelphij UTF-8 is special in that it supports multi-byte characters in 1160195941Sdelphij the input file. It is the only character set that supports 1161170256Sdelphij multi-byte characters. 116289019Sps 1163161475Sdelphij windows 1164195941Sdelphij Selects a character set appropriate for Microsoft Windows (cp 1165161475Sdelphij 1251). 116660786Sps 1167195941Sdelphij In rare cases, it may be desired to tailor [4mless[24m to use a character set 1168195941Sdelphij other than the ones definable by LESSCHARSET. In this case, the envi- 1169191930Sdelphij ronment variable LESSCHARDEF can be used to define a character set. It 1170191930Sdelphij should be set to a string where each character in the string represents 1171195941Sdelphij one character in the character set. The character "." is used for a 1172195941Sdelphij normal character, "c" for control, and "b" for binary. A decimal num- 1173195941Sdelphij ber may be used for repetition. For example, "bccc4b." would mean 1174195941Sdelphij character 0 is binary, 1, 2 and 3 are control, 4, 5, 6 and 7 are 1175161475Sdelphij binary, and 8 is normal. All characters after the last are taken to be 1176195941Sdelphij the same as the last, so characters 9 through 255 would be normal. 1177195941Sdelphij (This is an example, and does not necessarily represent any real char- 1178161475Sdelphij acter set.) 117960786Sps 1180195941Sdelphij This table shows the value of LESSCHARDEF which is equivalent to each 1181161475Sdelphij of the possible values for LESSCHARSET: 118289019Sps 1183128345Stjr ascii 8bcccbcc18b95.b 1184128345Stjr dos 8bcccbcc12bc5b95.b. 1185128345Stjr ebcdic 5bc6bcc7bcc41b.9b7.9b5.b..8b6.10b6.b9.7b 1186128345Stjr 9.8b8.17b3.3b9.7b9.8b8.6b10.b.b.b. 1187128345Stjr IBM-1047 4cbcbc3b9cbccbccbb4c6bcc5b3cbbc4bc4bccbc 1188128345Stjr 191.b 1189128345Stjr iso8859 8bcccbcc18b95.33b. 1190128345Stjr koi8-r 8bcccbcc18b95.b128. 119160786Sps latin1 8bcccbcc18b95.33b. 119260786Sps next 8bcccbcc18b95.bb125.bb 119360786Sps 1194195941Sdelphij If neither LESSCHARSET nor LESSCHARDEF is set, but any of the strings 1195222906Sdelphij "UTF-8", "UTF8", "utf-8" or "utf8" is found in the LC_ALL, LC_CTYPE or 1196161475Sdelphij LANG environment variables, then the default character set is utf-8. 119760786Sps 1198195941Sdelphij If that string is not found, but your system supports the [4msetlocale[0m 1199195941Sdelphij interface, [4mless[24m will use setlocale to determine the character set. 1200195941Sdelphij setlocale is controlled by setting the LANG or LC_CTYPE environment 1201161475Sdelphij variables. 120289019Sps 1203195941Sdelphij Finally, if the [4msetlocale[24m interface is also not available, the default 1204161475Sdelphij character set is latin1. 120589019Sps 1206195941Sdelphij Control and binary characters are displayed in standout (reverse 1207161475Sdelphij video). Each such character is displayed in caret notation if possible 1208195941Sdelphij (e.g. ^A for control-A). Caret notation is used only if inverting the 1209161475Sdelphij 0100 bit results in a normal printable character. Otherwise, the char- 1210195941Sdelphij acter is displayed as a hex number in angle brackets. This format can 1211195941Sdelphij be changed by setting the LESSBINFMT environment variable. LESSBINFMT 1212161475Sdelphij may begin with a "*" and one character to select the display attribute: 1213195941Sdelphij "*k" is blinking, "*d" is bold, "*u" is underlined, "*s" is standout, 1214195941Sdelphij and "*n" is normal. If LESSBINFMT does not begin with a "*", normal 1215195941Sdelphij attribute is assumed. The remainder of LESSBINFMT is a string which 1216195941Sdelphij may include one printf-style escape sequence (a % followed by x, X, o, 1217195941Sdelphij d, etc.). For example, if LESSBINFMT is "*u[%x]", binary characters 1218195941Sdelphij are displayed in underlined hexadecimal surrounded by brackets. The 1219221715Sdelphij default if no LESSBINFMT is specified is "*s<%02X>". Warning: the 1220221715Sdelphij result of expanding the character via LESSBINFMT must be less than 31 1221221715Sdelphij characters. 122260786Sps 1223161475Sdelphij When the character set is utf-8, the LESSUTFBINFMT environment variable 1224161475Sdelphij acts similarly to LESSBINFMT but it applies to Unicode code points that 1225195941Sdelphij were successfully decoded but are unsuitable for display (e.g., unas- 1226195941Sdelphij signed code points). Its default value is "<U+%04lX>". Note that 1227195941Sdelphij LESSUTFBINFMT and LESSBINFMT share their display attribute setting 1228195941Sdelphij ("*x") so specifying one will affect both; LESSUTFBINFMT is read after 1229195941Sdelphij LESSBINFMT so its setting, if any, will have priority. Problematic 1230195941Sdelphij octets in a UTF-8 file (octets of a truncated sequence, octets of a 1231195941Sdelphij complete but non-shortest form sequence, illegal octets, and stray 1232195941Sdelphij trailing octets) are displayed individually using LESSBINFMT so as to 1233161475Sdelphij facilitate diagnostic of how the UTF-8 file is ill-formed. 123460786Sps 1235161475Sdelphij 1236170256Sdelphij[1mPROMPTS[0m 1237195941Sdelphij The -P option allows you to tailor the prompt to your preference. The 1238195941Sdelphij string given to the -P option replaces the specified prompt string. 1239161475Sdelphij Certain characters in the string are interpreted specially. The prompt 1240195941Sdelphij mechanism is rather complicated to provide flexibility, but the ordi- 1241195941Sdelphij nary user need not understand the details of constructing personalized 1242161475Sdelphij prompt strings. 124360786Sps 1244195941Sdelphij A percent sign followed by a single character is expanded according to 1245161475Sdelphij what the following character is: 124660786Sps 1247195941Sdelphij %b[4mX[24m Replaced by the byte offset into the current input file. The b 1248170256Sdelphij is followed by a single character (shown as [4mX[24m above) which spec- 1249195941Sdelphij ifies the line whose byte offset is to be used. If the charac- 1250195941Sdelphij ter is a "t", the byte offset of the top line in the display is 1251173932Sdelphij used, an "m" means use the middle line, a "b" means use the bot- 1252195941Sdelphij tom line, a "B" means use the line just after the bottom line, 1253195941Sdelphij and a "j" means use the "target" line, as specified by the -j 1254173932Sdelphij option. 125560786Sps 125660786Sps %B Replaced by the size of the current input file. 125760786Sps 1258161475Sdelphij %c Replaced by the column number of the text appearing in the first 1259161475Sdelphij column of the screen. 126060786Sps 1261195941Sdelphij %d[4mX[24m Replaced by the page number of a line in the input file. The 1262170256Sdelphij line to be used is determined by the [4mX[24m, as with the %b option. 126360786Sps 1264195941Sdelphij %D Replaced by the number of pages in the input file, or equiva- 1265161475Sdelphij lently, the page number of the last line in the input file. 126660786Sps 1267195941Sdelphij %E Replaced by the name of the editor (from the VISUAL environment 1268195941Sdelphij variable, or the EDITOR environment variable if VISUAL is not 1269161475Sdelphij defined). See the discussion of the LESSEDIT feature below. 127060786Sps 127160786Sps %f Replaced by the name of the current input file. 127260786Sps 1273221715Sdelphij %F Replaced by the last component of the name of the current input 1274221715Sdelphij file. 1275221715Sdelphij 1276221715Sdelphij %i Replaced by the index of the current file in the list of input 1277161475Sdelphij files. 127860786Sps 1279221715Sdelphij %l[4mX[24m Replaced by the line number of a line in the input file. The 1280170256Sdelphij line to be used is determined by the [4mX[24m, as with the %b option. 128160786Sps 1282221715Sdelphij %L Replaced by the line number of the last line in the input file. 128360786Sps 128460786Sps %m Replaced by the total number of input files. 128560786Sps 1286195941Sdelphij %p[4mX[24m Replaced by the percent into the current input file, based on 1287195941Sdelphij byte offsets. The line used is determined by the [4mX[24m as with the 1288161475Sdelphij %b option. 128960786Sps 1290195941Sdelphij %P[4mX[24m Replaced by the percent into the current input file, based on 1291195941Sdelphij line numbers. The line used is determined by the [4mX[24m as with the 1292161475Sdelphij %b option. 129360786Sps 129489019Sps %s Same as %B. 129560786Sps 1296195941Sdelphij %t Causes any trailing spaces to be removed. Usually used at the 1297161475Sdelphij end of the string, but may appear anywhere. 129860786Sps 1299161475Sdelphij %x Replaced by the name of the next input file in the list. 130060786Sps 1301161475Sdelphij If any item is unknown (for example, the file size if input is a pipe), 1302161475Sdelphij a question mark is printed instead. 130360786Sps 1304195941Sdelphij The format of the prompt string can be changed depending on certain 1305195941Sdelphij conditions. A question mark followed by a single character acts like 1306195941Sdelphij an "IF": depending on the following character, a condition is evalu- 1307195941Sdelphij ated. If the condition is true, any characters following the question 1308195941Sdelphij mark and condition character, up to a period, are included in the 1309195941Sdelphij prompt. If the condition is false, such characters are not included. 1310195941Sdelphij A colon appearing between the question mark and the period can be used 1311161475Sdelphij to establish an "ELSE": any characters between the colon and the period 1312195941Sdelphij are included in the string if and only if the IF condition is false. 1313161475Sdelphij Condition characters (which follow a question mark) may be: 131460786Sps 1315221715Sdelphij ?a True if any characters have been included in the prompt so far. 131660786Sps 1317170256Sdelphij ?b[4mX[24m True if the byte offset of the specified line is known. 131860786Sps 131960786Sps ?B True if the size of current input file is known. 132060786Sps 1321161475Sdelphij ?c True if the text is horizontally shifted (%c is not zero). 132260786Sps 1323170256Sdelphij ?d[4mX[24m True if the page number of the specified line is known. 132460786Sps 132560786Sps ?e True if at end-of-file. 132660786Sps 1327221715Sdelphij ?f True if there is an input filename (that is, if input is not a 1328161475Sdelphij pipe). 132960786Sps 1330170256Sdelphij ?l[4mX[24m True if the line number of the specified line is known. 133163128Sps 1332161475Sdelphij ?L True if the line number of the last line in the file is known. 133363128Sps 133489019Sps ?m True if there is more than one input file. 133563128Sps 1336161475Sdelphij ?n True if this is the first prompt in a new input file. 133763128Sps 1338221715Sdelphij ?p[4mX[24m True if the percent into the current input file, based on byte 1339161475Sdelphij offsets, of the specified line is known. 134063128Sps 1341221715Sdelphij ?P[4mX[24m True if the percent into the current input file, based on line 1342161475Sdelphij numbers, of the specified line is known. 134363128Sps 1344128345Stjr ?s Same as "?B". 134560786Sps 1346221715Sdelphij ?x True if there is a next input file (that is, if the current 1347161475Sdelphij input file is not the last one). 134860786Sps 1349221715Sdelphij Any characters other than the special ones (question mark, colon, 1350221715Sdelphij period, percent, and backslash) become literally part of the prompt. 1351221715Sdelphij Any of the special characters may be included in the prompt literally 1352161475Sdelphij by preceding it with a backslash. 135360786Sps 135460786Sps Some examples: 135560786Sps 135660786Sps ?f%f:Standard input. 135760786Sps 1358221715Sdelphij This prompt prints the filename, if known; otherwise the string "Stan- 1359161475Sdelphij dard input". 136060786Sps 136160786Sps ?f%f .?ltLine %lt:?pt%pt\%:?btByte %bt:-... 136260786Sps 1363221715Sdelphij This prompt would print the filename, if known. The filename is fol- 1364221715Sdelphij lowed by the line number, if known, otherwise the percent if known, 1365221715Sdelphij otherwise the byte offset if known. Otherwise, a dash is printed. 1366221715Sdelphij Notice how each question mark has a matching period, and how the % 1367161475Sdelphij after the %pt is included literally by escaping it with a backslash. 136860786Sps 136960786Sps ?n?f%f .?m(file %i of %m) ..?e(END) ?x- Next\: %x..%t 137060786Sps 1371221715Sdelphij This prints the filename if this is the first prompt in a file, fol- 1372221715Sdelphij lowed by the "file N of N" message if there is more than one input 1373221715Sdelphij file. Then, if we are at end-of-file, the string "(END)" is printed 1374221715Sdelphij followed by the name of the next file, if there is one. Finally, any 1375161475Sdelphij trailing spaces are truncated. This is the default prompt. For refer- 1376221715Sdelphij ence, here are the defaults for the other two prompts (-m and -M 1377221715Sdelphij respectively). Each is broken into two lines here for readability 1378161475Sdelphij only. 137963128Sps 138089019Sps ?n?f%f .?m(file %i of %m) ..?e(END) ?x- Next\: %x.: 138189019Sps ?pB%pB\%:byte %bB?s/%s...%t 138263128Sps 138389019Sps ?f%f .?n?m(file %i of %m) ..?ltlines %lt-%lb?L/%L. : 138489019Sps byte %bB?s/%s. .?e(END) ?x- Next\: %x.:?pB%pB\%..%t 138563128Sps 138689019Sps And here is the default message produced by the = command: 138763128Sps 138889019Sps ?f%f .?m(file %i of %m) .?ltlines %lt-%lb?L/%L. . 1389128345Stjr byte %bB?s/%s. ?e(END) :?pB%pB\%..%t 1390128345Stjr 1391221715Sdelphij The prompt expansion features are also used for another purpose: if an 1392221715Sdelphij environment variable LESSEDIT is defined, it is used as the command to 1393221715Sdelphij be executed when the v command is invoked. The LESSEDIT string is 1394221715Sdelphij expanded in the same way as the prompt strings. The default value for 1395128345Stjr LESSEDIT is: 1396128345Stjr 139760786Sps %E ?lm+%lm. %f 139860786Sps 1399161475Sdelphij Note that this expands to the editor name, followed by a + and the line 1400221715Sdelphij number, followed by the file name. If your editor does not accept the 1401221715Sdelphij "+linenumber" syntax, or has other differences in invocation syntax, 1402161475Sdelphij the LESSEDIT variable can be changed to modify this default. 140360786Sps 140460786Sps 1405170256Sdelphij[1mSECURITY[0m 1406221715Sdelphij When the environment variable LESSSECURE is set to 1, [4mless[24m runs in a 1407161475Sdelphij "secure" mode. This means these features are disabled: 140860786Sps 140960786Sps ! the shell command 141060786Sps 141160786Sps | the pipe command 141260786Sps 141360786Sps :e the examine command. 141460786Sps 141560786Sps v the editing command 141660786Sps 141760786Sps s -o log files 141860786Sps 141960786Sps -k use of lesskey files 142060786Sps 142160786Sps -t use of tags files 142260786Sps 142360786Sps metacharacters in filenames, such as * 142460786Sps 142560786Sps filename completion (TAB, ^L) 142660786Sps 1427161475Sdelphij Less can also be compiled to be permanently in "secure" mode. 142860786Sps 142960786Sps 1430170256Sdelphij[1mCOMPATIBILITY WITH MORE[0m 1431170256Sdelphij If the environment variable LESS_IS_MORE is set to 1, or if the program 1432221715Sdelphij is invoked via a file link named "more", [4mless[24m behaves (mostly) in con- 1433221715Sdelphij formance with the POSIX "more" command specification. In this mode, 1434170256Sdelphij less behaves differently in these ways: 1435170256Sdelphij 1436221715Sdelphij The -e option works differently. If the -e option is not set, [4mless[0m 1437221715Sdelphij behaves as if the -E option were set. If the -e option is set, [4mless[0m 1438170256Sdelphij behaves as if the -e and -F options were set. 1439170256Sdelphij 1440221715Sdelphij The -m option works differently. If the -m option is not set, the 1441221715Sdelphij medium prompt is used, and it is prefixed with the string "--More--". 1442170256Sdelphij If the -m option is set, the short prompt is used. 1443170256Sdelphij 1444221715Sdelphij The -n option acts like the -z option. The normal behavior of the -n 1445170256Sdelphij option is unavailable in this mode. 1446170256Sdelphij 1447221715Sdelphij The parameter to the -p option is taken to be a [4mless[24m command rather 1448170256Sdelphij than a search pattern. 1449170256Sdelphij 1450221715Sdelphij The LESS environment variable is ignored, and the MORE environment 1451170256Sdelphij variable is used in its place. 1452170256Sdelphij 1453170256Sdelphij 1454170256Sdelphij[1mENVIRONMENT VARIABLES[0m 1455161475Sdelphij Environment variables may be specified either in the system environment 1456221715Sdelphij as usual, or in a [4mlesskey[24m (1) file. If environment variables are 1457221715Sdelphij defined in more than one place, variables defined in a local lesskey 1458221715Sdelphij file take precedence over variables defined in the system environment, 1459161475Sdelphij which take precedence over variables defined in the system-wide lesskey 1460161475Sdelphij file. 146160786Sps 1462128345Stjr COLUMNS 1463161475Sdelphij Sets the number of columns on the screen. Takes precedence over 1464221715Sdelphij the number of columns specified by the TERM variable. (But if 1465161475Sdelphij you have a windowing system which supports TIOCGWINSZ or 1466221715Sdelphij WIOCGETD, the window system's idea of the screen size takes 1467161475Sdelphij precedence over the LINES and COLUMNS environment variables.) 1468128345Stjr 146963128Sps EDITOR The name of the editor (used for the v command). 147060786Sps 1471221715Sdelphij HOME Name of the user's home directory (used to find a lesskey file 1472161475Sdelphij on Unix and OS/2 systems). 147360786Sps 147460786Sps HOMEDRIVE, HOMEPATH 1475221715Sdelphij Concatenation of the HOMEDRIVE and HOMEPATH environment vari- 1476161475Sdelphij ables is the name of the user's home directory if the HOME vari- 1477161475Sdelphij able is not set (only in the Windows version). 147860786Sps 1479221715Sdelphij INIT Name of the user's init directory (used to find a lesskey file 1480161475Sdelphij on OS/2 systems). 148160786Sps 148260786Sps LANG Language for determining the character set. 148360786Sps 148460786Sps LC_CTYPE 148560786Sps Language for determining the character set. 148660786Sps 1487170256Sdelphij LESS Options which are passed to [4mless[24m automatically. 148860786Sps 148960786Sps LESSANSIENDCHARS 1490221715Sdelphij Characters which may end an ANSI color escape sequence (default 1491161475Sdelphij "m"). 149260786Sps 1493161475Sdelphij LESSANSIMIDCHARS 1494221715Sdelphij Characters which may appear between the ESC character and the 1495221715Sdelphij end character in an ANSI color escape sequence (default 1496161475Sdelphij "0123456789;[?!"'#%()*+ ". 1497161475Sdelphij 149860786Sps LESSBINFMT 1499161475Sdelphij Format for displaying non-printable, non-control characters. 150060786Sps 150160786Sps LESSCHARDEF 150260786Sps Defines a character set. 150360786Sps 150489019Sps LESSCHARSET 150589019Sps Selects a predefined character set. 150663128Sps 150789019Sps LESSCLOSE 1508161475Sdelphij Command line to invoke the (optional) input-postprocessor. 150963128Sps 151089019Sps LESSECHO 1511161475Sdelphij Name of the lessecho program (default "lessecho"). The lessecho 1512221715Sdelphij program is needed to expand metacharacters, such as * and ?, in 1513161475Sdelphij filenames on Unix systems. 151463128Sps 1515161475Sdelphij LESSEDIT 1516221715Sdelphij Editor prototype string (used for the v command). See discus- 1517161475Sdelphij sion under PROMPTS. 151863128Sps 1519161475Sdelphij LESSGLOBALTAGS 1520221715Sdelphij Name of the command used by the -t option to find global tags. 1521170256Sdelphij Normally should be set to "global" if your system has the [4mglobal[0m 1522161475Sdelphij (1) command. If not set, global tags are not used. 152363128Sps 1524161475Sdelphij LESSHISTFILE 1525221715Sdelphij Name of the history file used to remember search commands and 1526221715Sdelphij shell commands between invocations of [4mless.[24m If set to "-" or 1527221715Sdelphij "/dev/null", a history file is not used. The default is 1528221715Sdelphij "$HOME/.lesshst" on Unix systems, "$HOME/_lesshst" on DOS and 1529221715Sdelphij Windows systems, or "$HOME/lesshst.ini" or "$INIT/lesshst.ini" 1530170256Sdelphij on OS/2 systems. 153163128Sps 1532161475Sdelphij LESSHISTSIZE 1533161475Sdelphij The maximum number of commands to save in the history file. The 1534161475Sdelphij default is 100. 153563128Sps 153660786Sps LESSKEY 153760786Sps Name of the default lesskey(1) file. 153860786Sps 153960786Sps LESSKEY_SYSTEM 154060786Sps Name of the default system-wide lesskey(1) file. 154160786Sps 154260786Sps LESSMETACHARS 1543221715Sdelphij List of characters which are considered "metacharacters" by the 1544161475Sdelphij shell. 154560786Sps 154660786Sps LESSMETAESCAPE 1547221715Sdelphij Prefix which less will add before each metacharacter in a com- 1548221715Sdelphij mand sent to the shell. If LESSMETAESCAPE is an empty string, 1549221715Sdelphij commands containing metacharacters will not be passed to the 1550161475Sdelphij shell. 155160786Sps 155260786Sps LESSOPEN 1553161475Sdelphij Command line to invoke the (optional) input-preprocessor. 155460786Sps 155560786Sps LESSSECURE 1556161475Sdelphij Runs less in "secure" mode. See discussion under SECURITY. 155760786Sps 155860786Sps LESSSEPARATOR 1559221715Sdelphij String to be appended to a directory name in filename comple- 1560161475Sdelphij tion. 156160786Sps 1562161475Sdelphij LESSUTFBINFMT 1563161475Sdelphij Format for displaying non-printable Unicode code points. 156460786Sps 1565170256Sdelphij LESS_IS_MORE 1566170256Sdelphij Emulate the [4mmore[24m (1) command. 1567170256Sdelphij 1568221715Sdelphij LINES Sets the number of lines on the screen. Takes precedence over 1569161475Sdelphij the number of lines specified by the TERM variable. (But if you 1570221715Sdelphij have a windowing system which supports TIOCGWINSZ or WIOCGETD, 1571221715Sdelphij the window system's idea of the screen size takes precedence 1572161475Sdelphij over the LINES and COLUMNS environment variables.) 157363128Sps 1574240121Sdelphij MORE Options which are passed to [4mless[24m automatically when running in 1575240121Sdelphij [4mmore[24m compatible mode. 1576240121Sdelphij 1577240121Sdelphij PATH User's search path (used to find a lesskey file on MS-DOS and 1578161475Sdelphij OS/2 systems). 157963128Sps 1580240121Sdelphij SHELL The shell used to execute the ! command, as well as to expand 1581161475Sdelphij filenames. 1582161475Sdelphij 1583170256Sdelphij TERM The type of terminal on which [4mless[24m is being run. 158463128Sps 1585128345Stjr VISUAL The name of the editor (used for the v command). 158660786Sps 158760786Sps 1588170256Sdelphij[1mSEE ALSO[0m 1589128345Stjr lesskey(1) 159060786Sps 159160786Sps 1592170256Sdelphij[1mCOPYRIGHT[0m 1593240121Sdelphij Copyright (C) 1984-2012 Mark Nudelman 159460786Sps 1595240121Sdelphij less is part of the GNU project and is free software. You can redis- 1596240121Sdelphij tribute it and/or modify it under the terms of either (1) the GNU Gen- 1597240121Sdelphij eral Public License as published by the Free Software Foundation; or 1598161475Sdelphij (2) the Less License. See the file README in the less distribution for 1599161475Sdelphij more details regarding redistribution. You should have received a copy 1600240121Sdelphij of the GNU General Public License along with the source for less; see 1601240121Sdelphij the file COPYING. If not, write to the Free Software Foundation, 59 1602240121Sdelphij Temple Place, Suite 330, Boston, MA 02111-1307, USA. You should also 1603161475Sdelphij have received a copy of the Less License; see the file LICENSE. 160460786Sps 1605161475Sdelphij less is distributed in the hope that it will be useful, but WITHOUT ANY 1606240121Sdelphij WARRANTY; without even the implied warranty of MERCHANTABILITY or FIT- 1607240121Sdelphij NESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 1608161475Sdelphij more details. 160960786Sps 161060786Sps 1611170256Sdelphij[1mAUTHOR[0m 1612251154Sdelphij Mark Nudelman 1613251154Sdelphij Send bug reports or comments to <bug-less@gnu.org> 1614191930Sdelphij See http://www.greenwoodsoftware.com/less/bugs.html for the latest list 1615191930Sdelphij of known bugs in less. 1616170256Sdelphij For more information, see the less homepage at 1617170256Sdelphij http://www.greenwoodsoftware.com/less. 161860786Sps 161960786Sps 162060786Sps 1621251154Sdelphij Version 458: 04 Apr 2013 LESS(1) 1622