1.\" $OpenBSD: lesskey.1,v 1.12 2014/11/23 08:01:06 bentley Exp $ 2.\" 3.\" Copyright (C) 2000-2012 Mark Nudelman 4.\" 5.\" Redistribution and use in source and binary forms, with or without 6.\" modification, are permitted provided that the following conditions 7.\" are met: 8.\" 1. Redistributions of source code must retain the above copyright 9.\" notice, this list of conditions and the following disclaimer. 10.\" 2. Redistributions in binary form must reproduce the above copyright 11.\" notice in the documentation and/or other materials provided with 12.\" the distribution. 13.\" 14.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY 15.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 17.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE 18.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 20.\" OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 21.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 22.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 23.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 24.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25.Dd $Mdocdate: November 23 2014 $ 26.Dt LESSKEY 1 27.Os 28.Sh NAME 29.Nm lesskey 30.Nd specify key bindings for less 31.Sh SYNOPSIS 32.Nm lesskey 33.Op Fl o Ar output | Fl -output Ns = Ns Ar output 34.Op Ar input 35.Nm lesskey 36.Fl V | -version 37.Sh DESCRIPTION 38.Nm 39is used to specify a set of key bindings to be used by 40.Xr less 1 . 41The input file is a text file which describes the key bindings. 42If the input file is 43.Sq - , 44standard input is read. 45If no input file is specified, a standard filename is used 46as the name of the input file; by default 47.Pa $HOME/.lesskey . 48.\" on MS-DOS systems, $HOME/_lesskey is used; 49.\" and on OS/2 systems $HOME/lesskey.ini is used, 50.\" or $INIT/lesskey.ini if $HOME is undefined. 51The output file is a binary file which is used by 52.Xr less 1 . 53If no output file is specified, and the environment variable 54.Ev LESSKEY 55is set, the value of 56.Ev LESSKEY 57is used as the name of the output file. 58Otherwise, a standard filename is used as the name of the output file; 59by default 60.Pa $HOME/.less 61is used. 62.\" on MS-DOS systems, $HOME/_less is used; 63.\" and on OS/2 systems, $HOME/less.ini is used, 64.\" or $INIT/less.ini if $HOME is undefined. 65If the output file already exists, 66.Nm 67will overwrite it. 68.Pp 69A system-wide lesskey file may also be set up to provide key bindings. 70If a key is defined in both a local lesskey file and in the 71system-wide file, key bindings in the local file take precedence over 72those in the system-wide file. 73If the environment variable 74.Ev LESSKEY_SYSTEM 75is set, 76.Xr less 1 77uses that as the name of the system-wide lesskey file. 78Otherwise, 79.Xr less 1 80looks in a standard place for the system-wide lesskey file: 81On 82.Ox , 83the system-wide lesskey file is 84.Pa /etc/sysless . 85.Pp 86The 87.Fl V 88or 89.Fl -version 90option causes 91.Nm 92to print its version number and immediately exit. 93If 94.Fl V 95or 96.Fl -version 97is present, other options and arguments are ignored. 98.Pp 99The input file consists of one or more sections. 100Each section starts with a line that identifies the type of section. 101Possible sections are: 102.Bl -tag -width "#line-edit" -offset indent 103.It #command 104Defines new command keys. 105.It #line-edit 106Defines new line-editing keys. 107.It #env 108Defines environment variables. 109.El 110.Pp 111Blank lines and lines which start with a pound sign 112.Pq Sq # 113are ignored, 114except for the special section header lines. 115.Sh COMMAND SECTION 116The command section begins with the line 117.Pp 118.Dl #command 119.Pp 120If the command section is the first section in the file, 121this line may be omitted. 122The command section consists of lines of the form: 123.Bd -filled -offset indent 124.Ar string 125.Aq whitespace 126.Ar action 127.Bq extra-string 128.Aq newline 129.Ed 130.Pp 131Whitespace is any sequence of one or more spaces and/or tabs. 132The 133.Ar string 134is the command key(s) which invoke the action. 135The 136.Ar string 137may be a single command key, or a sequence of up to 15 keys. 138The 139.Ar action 140is the name of the less action, from the list below. 141The characters in the 142.Ar string 143may appear literally, or be prefixed by a caret to indicate a control key. 144A backslash followed by one to three octal digits may be used to 145specify a character by its octal value. 146A backslash followed by certain characters specifies input 147characters as follows: 148.Pp 149.Bl -tag -width Ds -offset indent -compact 150.It \eb 151BACKSPACE 152.It \ee 153ESCAPE 154.It \en 155NEWLINE 156.It \er 157RETURN 158.It \et 159TAB 160.It \eku 161UP ARROW 162.It \ekd 163DOWN ARROW 164.It \ekr 165RIGHT ARROW 166.It \ekl 167LEFT ARROW 168.It \ekU 169PAGE UP 170.It \ekD 171PAGE DOWN 172.It \ekh 173HOME 174.It \eke 175END 176.It \ekx 177DELETE 178.El 179.Pp 180A backslash followed by any other character indicates that character is 181to be taken literally. 182Characters which must be preceded by backslash include 183caret, space, tab and the backslash itself. 184.Pp 185An action may be followed by an additional string. 186When such a command is entered while running less, 187the action is performed, and then the extra 188string is parsed, just as if it were typed into less. 189This feature can be used in certain cases to extend 190the functionality of a command. 191For example, see the 192.Cm { 193and 194.Cm :t 195commands in the example below. 196The extra string has a special meaning for the 197.Cm quit 198action: 199when less quits, 200the first character of the extra string is used as its exit status. 201.Pp 202The following input file describes the set of 203default command keys used by less: 204.Bd -literal -offset indent 205#command 206\er forw-line 207\en forw-line 208e forw-line 209j forw-line 210\ekd forw-line 211^E forw-line 212^N forw-line 213k back-line 214y back-line 215^Y back-line 216^K back-line 217^P back-line 218J forw-line-force 219K back-line-force 220Y back-line-force 221d forw-scroll 222^D forw-scroll 223u back-scroll 224^U back-scroll 225\e40 forw-screen 226f forw-screen 227^F forw-screen 228^V forw-screen 229\ekD forw-screen 230b back-screen 231^B back-screen 232\eev back-screen 233\ekU back-screen 234z forw-window 235w back-window 236\ee\e40 forw-screen-force 237F forw-forever 238\eeF forw-until-hilite 239R repaint-flush 240r repaint 241^R repaint 242^L repaint 243\eeu undo-hilite 244g goto-line 245\ekh goto-line 246< goto-line 247\ee< goto-line 248p percent 249% percent 250\ee[ left-scroll 251\ee] right-scroll 252\ee( left-scroll 253\ee) right-scroll 254{ forw-bracket {} 255} back-bracket {} 256( forw-bracket () 257) back-bracket () 258[ forw-bracket [] 259] back-bracket [] 260\ee^F forw-bracket 261\ee^B back-bracket 262G goto-end 263\ee> goto-end 264> goto-end 265\eke goto-end 266= status 267^G status 268:f status 269/ forw-search 270? back-search 271\ee/ forw-search * 272\ee? back-search * 273n repeat-search 274\een repeat-search-all 275N reverse-search 276\eeN reverse-search-all 277& filter 278m set-mark 279\' goto-mark 280^X^X goto-mark 281E examine 282:e examine 283^X^V examine 284:n next-file 285:p prev-file 286t next-tag 287T prev-tag 288:x index-file 289:d remove-file 290- toggle-option 291:t toggle-option t 292s toggle-option o 293_ display-option 294| pipe 295v visual 296! shell 297+ firstcmd 298H help 299h help 300V version 3010 digit 3021 digit 3032 digit 3043 digit 3054 digit 3065 digit 3076 digit 3087 digit 3098 digit 3109 digit 311q quit 312Q quit 313:q quit 314:Q quit 315ZZ quit 316.Ed 317.Sh PRECEDENCE 318Commands specified by 319.Nm 320take precedence over the default commands. 321A default command key may be disabled by including it in the 322input file with the action 323.Cm invalid . 324Alternatively, a key may be defined 325to do nothing by using the action 326.Cm noaction . 327.Cm noaction 328is similar to 329.Cm invalid , 330but less will give an error beep for an 331.Cm invalid 332command, but not for a 333.Cm noaction 334command. 335In addition, all default commands may be disabled by 336adding this control line to the input file: 337.Pp 338.Dl #stop 339.Pp 340This will cause all default commands to be ignored. 341The 342.Cm #stop 343line should be the last line in that section of the file. 344.Pp 345Be aware that 346.Cm #stop 347can be dangerous. 348Since all default commands are disabled, you must provide sufficient 349commands before the 350.Cm #stop 351line to enable all necessary actions. 352For example, failure to provide a 353.Cm quit 354command can lead to frustration. 355.Sh LINE EDITING SECTION 356The line-editing section begins with the line: 357.Pp 358.Dl #line-edit 359.Pp 360This section specifies new key bindings for the line editing commands, 361in a manner similar to the way key bindings for 362ordinary commands are specified in the #command section. 363The line-editing section consists of a list of keys and actions, 364one per line as in the example below. 365.Pp 366The following input file describes the set of 367default line-editing keys used by less: 368.Bd -literal -offset indent 369#line-edit 370\et forw-complete 371\e17 back-complete 372\ee\et back-complete 373^L expand 374^V literal 375^A literal 376\eel right 377\ekr right 378\eeh left 379\ekl left 380\eeb word-left 381\ee\ekl word-left 382\eew word-right 383\ee\ekr word-right 384\eei insert 385\eex delete 386\ekx delete 387\eeX word-delete 388\eekx word-delete 389\ee\eb word-backspace 390\ee0 home 391\ekh home 392\ee$ end 393\eke end 394\eek up 395\eku up 396\eej down 397^G abort 398.Ed 399.Sh ENVIRONMENT SECTION 400The environment variable section begins with the line 401.Pp 402.Dl #env 403.Pp 404Following this line is a list of environment variable assignments. 405Each line consists of an environment variable name, an equals sign 406.Pq Sq = 407and the value to be assigned to the environment variable. 408Whitespace before and after the equals sign is ignored. 409Variables assigned in this way are visible only to less. 410If environment variables are defined in more than one place, 411variables defined in a local lesskey file take precedence over 412variables defined in the system environment, which take precedence 413over variables defined in the system-wide lesskey file. 414Although the lesskey file can be used to override variables set in the 415environment, the main purpose of assigning variables in the lesskey file 416is simply to have all less configuration information stored in one file. 417.Pp 418The following input file sets the 419.Fl i 420option whenever less is run, 421and specifies the character set to be 422.Cm latin1 : 423.Bd -literal -offset indent 424#env 425LESS = -i 426LESSCHARSET = latin1 427.Ed 428.Sh ENVIRONMENT 429.Bl -tag -width LESSKEY_SYSTEM -compact 430.It Ev LESSKEY 431Name of the default 432.Nm 433file. 434.It Ev LESSKEY_SYSTEM 435Name of the default system-wide 436.Nm 437file. 438.El 439.Sh FILES 440.Bl -tag -width "$HOME/.lesskey" -compact 441.It Pa $HOME/.less 442Default 443.Nm 444file. 445.It Pa $HOME/.lesskey 446Default 447.Nm 448input file. 449.It Pa /etc/sysless 450Default system-wide 451.Nm 452file. 453.El 454.Sh SEE ALSO 455.Xr less 1 456.Sh AUTHORS 457.An Mark Nudelman 458.Pp 459Send bug reports or comments to 460.Aq Mt bug-less@gnu.org . 461.\" .Sh CAVEATS 462.\" On MS-DOS and OS/2 systems, certain keys send a sequence of characters 463.\" which start with a NUL character (0). 464.\" This NUL character should be represented as \e340 in a lesskey file. 465