1LESSKEY(1) General Commands Manual LESSKEY(1) 2 3 4 5[1mNAME[0m 6 lesskey - customize key bindings for less 7 8[1mSYNOPSIS (deprecated)[0m 9 [1mlesskey [-o output] [--] [input][0m 10 [1mlesskey [--output=output] [--] [input][0m 11 [1mlesskey -V[0m 12 [1mlesskey --version[0m 13 14[1mSCOPE[0m 15 This document describes the format of the [1mlesskey [22msource file, which is 16 used by [1mless [22mversion 582 and later. In previous versions of [1mless[22m, a 17 separate program called [1mlesskey [22mwas used to compile the [1mlesskey [22msource 18 file into a format understood by [1mless[22m. This compilation step is no 19 longer required and the [1mlesskey [22mprogram is therefore deprecated, al‐ 20 though the file format remains supported by [1mless [22mitself. 21 22[1mDESCRIPTION[0m 23 A [1mlesskey [22mfile specifies a set of key bindings and environment vari‐ 24 ables to be used by subsequent invocations of [1mless[22m. 25 26[1mFILE FORMAT[0m 27 The input file consists of one or more [4msections[24m. Each section starts 28 with a line that identifies the type of section. Possible sections 29 are: 30 31 #command 32 Customizes command key bindings. 33 34 #line-edit 35 Customizes line-editing key bindings. 36 37 #env Defines environment variables. 38 39 Blank lines and lines which start with a hash mark (#) are ignored, ex‐ 40 cept as noted below. 41 42[1mCOMMAND SECTION[0m 43 The command section begins with the line 44 45 #command 46 47 If the command section is the first section in the file, this line may 48 be omitted. The command section consists of lines of the form: 49 50 [4mstring[24m <whitespace> [4maction[24m [extra-string] <newline> 51 52 Whitespace is any sequence of one or more spaces and/or tabs. The 53 [4mstring[24m is the command key(s) which invoke the action. The [4mstring[24m may 54 be a single command key, or a sequence of up to 15 keys. The [4maction[24m is 55 the name of the less action, from the list below. The characters in 56 the [4mstring[24m may appear literally, or be prefixed by a caret to indicate 57 a control key. A backslash followed by one to three octal digits may 58 be used to specify a character by its octal value. A backslash fol‐ 59 lowed by certain characters specifies input characters as follows: 60 61 \b BACKSPACE (0x08) 62 \e ESCAPE (0x1B) 63 \n NEWLINE (0x0A) 64 \r RETURN (0x0D) 65 \t TAB (0x09) 66 67 \k followed by a single character represents the char(s) produced 68 when one of these keys is pressed: 69 70 \kb BACKSPACE (the BACKSPACE key) 71 \kB ctrl-BACKSPACE 72 \kd DOWN ARROW 73 \kD PAGE DOWN 74 \ke END 75 \kh HOME 76 \ki INSERT 77 \kl LEFT ARROW 78 \kL ctrl-LEFT ARROW 79 \kr RIGHT ARROW 80 \kR ctrl-RIGHT ARROW 81 \kt BACKTAB 82 \ku UP ARROW 83 \kU PAGE UP 84 \kx DELETE 85 \kX ctrl-DELETE 86 \k1 F1 87 88 89 A backslash followed by any other character indicates that charac‐ 90 ter is to be taken literally. Characters which must be preceded 91 by backslash include caret, space, tab, hash mark and the back‐ 92 slash itself. 93 94 An action may be followed by an "extra" string. When such a com‐ 95 mand is entered while running [1mless[22m, the action is performed, and 96 then the extra string is parsed, just as if it were typed in to 97 [1mless[22m. This feature can be used in certain cases to extend the 98 functionality of a command. For example, see the "{" and ":t" 99 commands in the example below. The extra string has a special 100 meaning for the "quit" action: when [1mless [22mquits, the first charac‐ 101 ter of the extra string is used as its exit status. 102 103[1mEXAMPLE[0m 104 The following input file describes the set of default command keys used 105 by [1mless[22m. Documentation on each command can be found in the man page, 106 under the key sequence which invokes the command. 107 108 109 #command 110 \r forw-line 111 \n forw-line 112 e forw-line 113 j forw-line 114 \kd forw-line 115 ^E forw-line 116 ^N forw-line 117 k back-line 118 y back-line 119 ^Y back-line 120 ^K back-line 121 ^P back-line 122 J forw-line-force 123 K back-line-force 124 Y back-line-force 125 d forw-scroll 126 ^D forw-scroll 127 u back-scroll 128 ^U back-scroll 129 \40 forw-screen 130 f forw-screen 131 ^F forw-screen 132 133 ^V forw-screen 134 \kD forw-screen 135 b back-screen 136 ^B back-screen 137 \ev back-screen 138 \kU back-screen 139 z forw-window 140 w back-window 141 \e\40 forw-screen-force 142 F forw-forever 143 \eF forw-until-hilite 144 R repaint-flush 145 r repaint 146 ^R repaint 147 ^L repaint 148 \eu undo-hilite 149 \eU clear-search 150 g goto-line 151 \kh goto-line 152 < goto-line 153 \e< goto-line 154 p percent 155 % percent 156 \e[ left-scroll 157 \e] right-scroll 158 \e( left-scroll 159 \e) right-scroll 160 \kl left-scroll 161 \kr right-scroll 162 \e{ no-scroll 163 \e} end-scroll 164 { forw-bracket {} 165 } back-bracket {} 166 ( forw-bracket () 167 ) back-bracket () 168 [ forw-bracket [] 169 ] back-bracket [] 170 \e^F forw-bracket 171 \e^B back-bracket 172 G goto-end 173 \e> goto-end 174 > goto-end 175 \ke goto-end 176 \eG goto-end-buffered 177 = status 178 ^G status 179 :f status 180 / forw-search 181 ? back-search 182 \e/ forw-search * 183 \e? back-search * 184 n repeat-search 185 \en repeat-search-all 186 N reverse-search 187 \eN reverse-search-all 188 & filter 189 m set-mark 190 M set-mark-bottom 191 \em clear-mark 192 ' goto-mark 193 ^X^X goto-mark 194 E examine 195 :e examine 196 ^X^V examine 197 :n next-file 198 199 :p prev-file 200 t next-tag 201 T prev-tag 202 :x index-file 203 :d remove-file 204 - toggle-option 205 :t toggle-option t 206 s toggle-option o 207 ## Use a long option name by starting the 208 ## extra string with ONE dash; eg: 209 ## s toggle-option -log-file\n 210 _ display-option 211 | pipe 212 v visual 213 ! shell 214 # pshell 215 + firstcmd 216 H help 217 h help 218 V version 219 0 digit 220 1 digit 221 2 digit 222 3 digit 223 4 digit 224 5 digit 225 6 digit 226 7 digit 227 8 digit 228 9 digit 229 q quit 230 Q quit 231 :q quit 232 :Q quit 233 ZZ quit 234 235 236[1mPRECEDENCE[0m 237 Commands specified by [1mlesskey [22mtake precedence over the default com‐ 238 mands. A default command key may be disabled by including it in the 239 input file with the action "invalid". Alternatively, a key may be de‐ 240 fined to do nothing by using the action "noaction". "noaction" is sim‐ 241 ilar to "invalid", but [1mless [22mwill give an error beep for an "invalid" 242 command, but not for a "noaction" command. In addition, ALL default 243 commands may be disabled by adding this control line to the input file: 244 245 #stop 246 247 This will cause all default commands to be ignored. The #stop line 248 should be the last line in that section of the file. 249 250 Be aware that #stop can be dangerous. Since all default commands are 251 disabled, you must provide sufficient commands before the #stop line to 252 enable all necessary actions. For example, failure to provide a "quit" 253 command can lead to frustration. 254 255[1mLINE EDITING SECTION[0m 256 The line-editing section begins with the line: 257 258 #line-edit 259 260 This section specifies new key bindings for the line editing commands, 261 in a manner similar to the way key bindings for ordinary commands are 262 specified in the #command section. The line-editing section consists 263 of a list of keys and actions, one per line as in the example below. 264 265[1mEXAMPLE[0m 266 The following input file describes the set of default line-editing keys 267 used by [1mless[22m: 268 269 270 #line-edit 271 \t forw-complete 272 \17 back-complete 273 \e\t back-complete 274 ^L expand 275 ^V literal 276 ^A literal 277 \el right 278 \kr right 279 \eh left 280 \kl left 281 \eb word-left 282 \e\kl word-left 283 \ew word-right 284 \e\kr word-right 285 \ei insert 286 \ex delete 287 \kx delete 288 \eX word-delete 289 \ekx word-delete 290 \e\b word-backspace 291 \e0 home 292 \kh home 293 \e$ end 294 \ke end 295 \ek up 296 \ku up 297 \ej down 298 ^G abort 299 300 301[1mLESS ENVIRONMENT VARIABLES[0m 302 The environment variable section begins with the line 303 304 #env 305 306 Following this line is a list of environment variable assignments. 307 Each line consists of an environment variable name, an equals sign (=) 308 and the value to be assigned to the environment variable. White space 309 before and after the equals sign is ignored. Variables assigned in 310 this way are visible only to [1mless[22m. If a variable is specified in the 311 system environment and also in a lesskey file, the value in the lesskey 312 file takes precedence. 313 314 If the variable name is followed by += rather than =, the string is ap‐ 315 pended to the variable's existing value. This currently works only if 316 any += lines immediately follow the same variable's original definition 317 (with an = line), without any intervening definitions of other vari‐ 318 ables. It can append only to a variable defined earlier in the file; 319 it cannot append to a variable in the system environment. The string 320 is appended literally, without any extra whitespace added, so if white‐ 321 space is desired, it should be appended to the end of the preceding 322 line. (It cannot be added to the beginning of the += string because 323 space after the equals sign is ignored, as noted above.) 324 325[1mCONDITIONAL CONFIGURATION[0m 326 If a line begins with #version followed by a relational operator and a 327 version number, the remainder of the line is parsed if and only if the 328 running version of [1mless [22m(or [1mlesskey[22m) matches the operator. This can be 329 helpful if a lesskey file is used by different versions of [1mless[22m. 330 331 For example, suppose that a new command named 'sideways-search' is 332 added in [1mless [22mversion 777. Then the following line would assign the 333 command to the Q key, but only in versions of [1mless [22mwhich support it. 334 The line would be ignored by versions earlier than 777. 335 336 #version >= 777 Q sideways-search 337 338 These six operators are supported: 339 340 > Greater than 341 < Less than 342 >= Greater than or equal to 343 <= Less than or equal to 344 = Equal to 345 != Not equal to 346 347 The #version feature is not supported in [1mless [22mand [1mlesskey [22mbefore ver‐ 348 sion 594. In those older versions, all #version lines are ignored. 349 350[1mEXAMPLE[0m 351 The following input file sets the -i and -S options when is run and, on 352 version 595 and higher, adds a --color option. 353 354 #env 355 ## (Note that there must be a space at the end of the next line, 356 ## to separate the --color option from the -S option.) 357 LESS = -i -S 358 #version >= 595 LESS += --color=Hkc 359 360[1mSEE ALSO[0m 361 [1mless[22m(1) 362 363[1mWARNINGS[0m 364 On MS-DOS and OS/2 systems, certain keys send a sequence of characters 365 which start with a NUL character (0). This NUL character should be 366 represented as \340 in a lesskey file. 367 368[1mCOPYRIGHT[0m 369 Copyright (C) 1984-2023 Mark Nudelman 370 371 less is part of the GNU project and is free software. You can redis‐ 372 tribute it and/or modify it under the terms of either (1) the GNU Gen‐ 373 eral Public License as published by the Free Software Foundation; or 374 (2) the Less License. See the file README in the less distribution for 375 more details regarding redistribution. You should have received a copy 376 of the GNU General Public License along with the source for less; see 377 the file COPYING. If not, write to the Free Software Foundation, 59 378 Temple Place, Suite 330, Boston, MA 02111-1307, USA. You should also 379 have received a copy of the Less License; see the file LICENSE. 380 381 less is distributed in the hope that it will be useful, but WITHOUT ANY 382 WARRANTY; without even the implied warranty of MERCHANTABILITY or FIT‐ 383 NESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 384 more details. 385 386[1mAUTHOR[0m 387 Mark Nudelman 388 Report bugs at https://github.com/gwsw/less/issues. 389 390 391 392 Version 643: 20 Jul 2023 LESSKEY(1) 393