Debian Codegraph @

upstream/fedora-44/man1/lesskey.1

raw
1 '\" t
2 .TH LESSKEY 1 "10 Jan 2026" "less 691"
3 .\" Define a string for the caret ("hat") as portably as possible.
4 .ie \n(.g .ds ^ \(ha
5 .el .ds ^ ^
6 .\" Define a string for the neutral apostrophe as portably as possible.
7 .ie \n(.g .ds ' \(aq
8 .el .ds ' '
9 .\" Define a string to interpolate the hyphenless break point escape
10 .\" sequence (for URLs and similar) if the formatter claims groff
11 .\" compatibility, else interpolate nothing.
12 .ie \n(.g .ds : \:
13 .el .ds : \" empty
14 .SH NAME
15 lesskey \- customize key bindings for less
16 .SH "SYNOPSIS (deprecated)"
17 .B lesskey
18 .RB [ \-o
19 .IR output ]
20 .B \-\-
21 .I input
22 .br
23 .B lesskey
24 .RB [ \-\-output=\c
25 .IR output ]
26 .B \-\-
27 .I input
28 .PP
29 .B "lesskey \-V"
30 .br
31 .B "lesskey \-\-version"
32 .SH SCOPE
33 This document describes the format of the
34 .B lesskey
35 source file, which is used by
36 .B less
37 version 582 and later.
38 In previous versions of
39 .BR less ,
40 a separate program called
41 .B lesskey
42 was used to compile the
43 .B lesskey
44 source file into a format understood by
45 .BR less .
46 This compilation step is no longer required and the
47 .B lesskey
48 program is therefore deprecated, although the file format remains supported by
49 .B less
50 itself.
51 .PP
52 .SH DESCRIPTION
53 A
54 .B lesskey
55 file specifies a set of key bindings and environment variables
56 to be used by subsequent invocations of
57 .BR less .
58 .SH FILE FORMAT
59 The input file consists of one or more
60 .IR sections .
61 Each section starts with a line that identifies the type of section.
62 Possible sections are:
63 .IP #command
64 Customizes command key bindings.
65 .IP #line\-edit
66 Customizes line-editing key bindings.
67 .IP #env
68 Defines environment variables.
69 .PP
70 Blank lines are ignored.
71 Any text that follows an unescaped hash mark (#) in a line is ignored,
72 except as noted below.
73 .
74 .SH "COMMAND SECTION"
75 The command section begins with the line
76 .PP
77 #command
78 .PP
79 If the command section is the first section in the file,
80 this line may be omitted.
81 The command section consists of lines of the form:
82 .PP
83 \fIstring\fP <whitespace> \fIaction\fP <whitespace> [extra-string] <newline>
84 .PP
85 Whitespace is any sequence of one or more spaces and/or tabs.
86 The \fIstring\fP is the command key(s) which invoke the action.
87 The \fIstring\fP may be a single command key, or a sequence of up to 15 keys.
88 The \fIaction\fP is the name of the less action,
89 from the lists in the EXAMPLE sections below.
90 The characters in the \fIstring\fP may appear literally, or be
91 prefixed by a caret to indicate a control key.
92 A backslash followed by one to three octal digits may be used to
93 specify a character by its octal value.
94 A backslash followed by certain characters specifies input
95 characters as follows:
96 .RS 5m
97 .TS
98 l l l.
99 \eb BACKSPACE (0x08)
100 \ee ESCAPE (0x1B)
101 \en NEWLINE (0x0A)
102 \er RETURN (0x0D)
103 \et TAB (0x09)
104 .TE
105 .RE
106 .PP
107 \ek followed by one or two characters represents the char(s) produced
108 when one of these keys is pressed:
109 .RS 5m
110 .TS
111 l l.
112 \ekb BACKSPACE (the BACKSPACE key)
113 \ekB ctrl-BACKSPACE
114 \ekd DOWN ARROW
115 \ekD PAGE DOWN
116 \eke END
117 \ekh HOME
118 \eki INSERT
119 \ekl LEFT ARROW
120 \ekL ctrl-LEFT ARROW
121 \ekr RIGHT ARROW
122 \ekR ctrl-RIGHT ARROW
123 \ekt BACKTAB
124 \eku UP ARROW
125 \ekU PAGE UP
126 \ekx DELETE
127 \ekX ctrl-DELETE
128 \ek1 F1
129 \ekp1 lower left key on the numeric keypad
130 \ekp2 lower center key on the numeric keypad
131 \ekp3 lower right key on the numeric keypad
132 \ekp4 center left key on the numeric keypad
133 \ekp5 center key on the numeric keypad
134 \ekp6 center right key on the numeric keypad
135 \ekp7 upper left key on the numeric keypad
136 \ekp8 upper center key on the numeric keypad
137 \ekp9 upper right key on the numeric keypad
138 \ekp0 0 on the numeric keypad
139 \ekp* * on the numeric keypad
140 \ekp/ / on the numeric keypad
141 \ekp\- \- on the numeric keypad
142 \ekp+ + on the numeric keypad
143 \ekp. . on the numeric keypad
144 \ekp, , on the numeric keypad
145 .TE
146 .RE
147 .PP
148 A backslash followed by any other character indicates that character is
149 to be taken literally.
150 Characters which must be preceded by backslash include
151 caret, space, tab, hash mark and the backslash itself.
152 .PP
153 An action may be followed by an "extra" string.
154 When such a command is entered while running
155 .BR less ,
156 the action is performed, and then the extra
157 string is parsed, just as if it were typed in to
158 .BR less .
159 This feature can be used in certain cases to extend
160 the functionality of a command.
161 For example, see the "{" and ":t" commands in the example below.
162 It can also be used to execute more than one command when a key is pressed.
163 For example, if this line were in a lesskey file, pressing the "B" key
164 would first set the "b" mark and then search for the string "next":
165 .PP
166 .EX
167 .nf
168 B set\-mark b/next\en
169 .fi
170 .EE
171 .PP
172 The extra string has a special meaning for the "quit" action:
173 when
174 .B less
175 quits, the ASCII value of the first character of the extra string
176 is used as its exit status.
177 .
178 .SH EXAMPLE
179 The following input file describes the set of
180 default command keys used by
181 .BR less .
182 Documentation on each command can be found in the
183 .B less
184 man page, under the key sequence which invokes the command.
185 .PP
186 .RS 5m
187 .TS
188 l l.
189 #command
190 \er forw\-line
191 \en forw\-line
192 e forw\-line
193 j forw\-line
194 \ekd forw\-line
195 \*^E forw\-line
196 \*^N forw\-line
197 k back\-line
198 y back\-line
199 \*^Y back\-line
200 \*^K back\-line
201 \*^P back\-line
202 J forw\-line\-force
203 K back\-line\-force
204 Y back\-line\-force
205 \eej forw\-newline
206 \eek back\-newline
207 d forw\-scroll
208 \*^D forw\-scroll
209 u back\-scroll
210 \*^U back\-scroll
211 \e40 forw\-screen
212 f forw\-screen
213 \*^F forw\-screen
214 \*^V forw\-screen
215 \ekD forw\-screen
216 b back\-screen
217 \*^B back\-screen
218 \eev back\-screen
219 \ekU back\-screen
220 z forw\-window
221 w back\-window
222 \ee\e40 forw\-screen\-force
223 \eeb back\-screen\-force
224 F forw\-forever
225 \eeF forw\-until\-hilite
226 R repaint\-flush
227 r repaint
228 \*^R repaint
229 \*^L repaint
230 \eeu undo\-hilite
231 \eeU clear\-search
232 g goto\-line
233 \ekh goto\-line
234 < goto\-line
235 \ee< goto\-line
236 p percent
237 % percent
238 \ee( left\-scroll
239 \ee) right\-scroll
240 \ekl left\-scroll
241 \ekr right\-scroll
242 \ee{ no\-scroll
243 \ee} end\-scroll
244 { forw\-bracket {}
245 } back\-bracket {}
246 ( forw\-bracket ()
247 ) back\-bracket ()
248 [ forw\-bracket []
249 ] back\-bracket []
250 \ee\*^F forw\-bracket
251 \ee\*^B back\-bracket
252 G goto\-end
253 \ee> goto\-end
254 > goto\-end
255 \eke goto\-end
256 \eeG goto\-end\-buffered
257 \&= status
258 \*^G status
259 :f status
260 / forw\-search
261 ? back\-search
262 \ee/ forw\-search *
263 \ee? back\-search *
264 n repeat\-search
265 \een repeat\-search\-all
266 N reverse\-search
267 \eeN reverse\-search\-all
268 \*^O\*^N osc8\-forw\-search
269 \*^On osc8\-forw\-search
270 \*^O\*^P osc8\-back\-search
271 \*^Op osc8\-back\-search
272 \*^O\*^O osc8\-open
273 & filter
274 m set\-mark
275 M set\-mark\-bottom
276 \eem clear\-mark
277 \&\*' goto\-mark
278 \*^X\*^X goto\-mark
279 E examine
280 :e examine
281 \*^X\*^V examine
282 :n next\-file
283 :p prev\-file
284 t next\-tag
285 T prev\-tag
286 :x index\-file
287 :d remove\-file
288 \- toggle\-option
289 :t toggle\-option t
290 s toggle\-option o
291 ## Use a long option name by starting the
292 ## extra string with ONE dash; eg:
293 ## s toggle\-option \-log\-file\en
294 \&_ display\-option
295 \ekp1 goto\-end
296 \ekp2 forw\-line
297 \ekp3 forw\-screen
298 \ekp4 left\-scroll
299 \ekp6 right\-scroll
300 \ekp7 goto\-line
301 \ekp8 back\-line
302 \ekp9 back\-screen
303 \ekp0 noaction 0
304 \ekp* noaction *
305 \ekp/ noaction /
306 \ekp\- noaction \-
307 \ekp+ noaction +
308 \ekp. noaction .
309 \ekp, noaction ,
310 | pipe
311 v visual
312 ! shell
313 # pshell
314 + firstcmd
315 \ee[M mouse
316 \ee[< mouse6
317 H help
318 h help
319 V version
320 0 digit
321 1 digit
322 2 digit
323 3 digit
324 4 digit
325 5 digit
326 6 digit
327 7 digit
328 8 digit
329 9 digit
330 q quit
331 Q quit
332 :q quit
333 :Q quit
334 ZZ quit
335 .TE
336 .RE
337 .SH PRECEDENCE
338 Commands specified by
339 .B lesskey
340 take precedence over the default commands.
341 A default command key may be disabled by including it in the
342 input file with the action "invalid".
343 Alternatively, a key may be defined
344 to do nothing by using the action "noaction".
345 "noaction" is similar to "invalid", but
346 .B less
347 will give an error beep for an "invalid" command,
348 but not for a "noaction" command.
349 In addition, ALL default commands may be disabled by
350 adding this control line to the input file:
351 .PP
352 #stop
353 .PP
354 This will cause all default commands to be ignored.
355 The #stop line should be the last line in that section of the file.
356 .PP
357 Be aware that #stop can be dangerous.
358 Since all default commands are disabled,
359 you must provide sufficient commands before the #stop line
360 to enable all necessary actions.
361 For example, failure to provide a "quit" command can lead to frustration.
362 .
363 .SH "LINE EDITING SECTION"
364 The line-editing section begins with the line:
365 .PP
366 .EX
367 #line\-edit
368 .EE
369 .PP
370 This section specifies new key bindings for the line editing commands,
371 in a manner similar to the way key bindings for
372 ordinary commands are specified in the #command section.
373 The line-editing section consists of a list of keys and actions,
374 one per line as in the example below.
375 .
376 .SH EXAMPLE
377 The following input file describes the set of
378 default line-editing keys used by
379 .BR less :
380 .PP
381 .RS 5m
382 .TS
383 l l.
384 #line\-edit
385 \et forw\-complete
386 \e17 back\-complete
387 \ee\et back\-complete
388 ^L expand
389 ^V literal
390 ^A literal
391 \eel right
392 \ekr right
393 \eeh left
394 \ekl left
395 \eeb word\-left
396 \ee\ekl word\-left
397 \eew word\-right
398 \ee\ekr word\-right
399 \eei insert
400 \eex delete
401 \ekx delete
402 \eeX word\-delete
403 \eekx word\-delete
404 \ee\eb word\-backspace
405 \ee0 home
406 \ekh home
407 \ee$ end
408 \eke end
409 \eek up
410 \eku up
411 \eej down
412 ^G abort
413 \ekp1 end
414 \ekp2 down
415 \ekp4 left
416 \ekp6 right
417 \ekp7 home
418 \ekp8 up
419 \ekp0 noaction 0
420 \ekp* noaction *
421 \ekp/ noaction /
422 \ekp\- noaction \-
423 \ekp+ noaction +
424 \ekp. noaction .
425 \ekp, noaction ,
426 \ee[M mouse
427 \ee[< mouse6
428 .TE
429 .RE
430 .
431 .SH "LESS ENVIRONMENT VARIABLES"
432 The environment variable section begins with the line
433 .PP
434 #env
435 .PP
436 Following this line is a list of environment variable assignments.
437 Each line consists of an environment variable name, an equals sign (=)
438 and the value to be assigned to the environment variable.
439 White space before and after the equals sign is ignored.
440 Variables assigned in this way are visible only to
441 .BR less .
442 If a variable is specified in the system environment and also in a
443 lesskey file, the value in the lesskey file takes precedence.
444 .
445 .PP
446 If the variable name is followed by += rather than =,
447 the string is appended to the variable's existing value.
448 This currently works only if any += lines immediately follow
449 the same variable's original definition (with an = line),
450 without any intervening definitions of other variables.
451 It can append only to a variable defined earlier in the file;
452 it cannot append to a variable in the system environment.
453 The string is appended literally, without any extra whitespace added,
454 so if whitespace is desired,
455 it should be appended to the end of the preceding line.
456 (It cannot be added to the beginning of the += string because space after
457 the equals sign is ignored, as noted above.)
458 .
459 .PP
460 In the string after the = sign, a substring of the form ${NAME}
461 is replaced with the value of the environment variable "NAME".
462 The value of the variable may come from either the system environment,
463 an earlier lesskey file, or an earlier definition in the current lesskey file.
464 Simple text replacements can be performed by using
465 the syntax ${NAME/STRING/REPL}.
466 This replaces all instances of "STRING" in the named
467 environment variable with the text "REPL".
468 STRING is matched using a simple text comparison;
469 no metacharacters are supported.
470 An instance of slash or right curly bracket in STRING or REPL
471 must be escaped by preceding it with \fItwo\fP backslashes.
472 If REPL is an empty string, all instances of STRING are removed.
473 A slash immediately before the right curly bracket may be omitted.
474 Multiple replacements may be performed by using
475 the syntax ${NAME/STRING1/REPL1/STRING2/REPL2} and so on.
476 .
477 .SH CONDITIONAL CONFIGURATION
478 If a line begins with #version followed by a relational operator and a version number,
479 the remainder of the line is parsed if and only if the running version of
480 .B less
481 (or
482 .BR lesskey )
483 matches the operator.
484 This can be helpful if a lesskey file is used by different versions of
485 .BR less .
486 .PP
487 For example, suppose that a new command named 'sideways\-search' is added in
488 .B less
489 version 777.
490 Then the following line would assign the command to the Q key, but only in versions of
491 .B less
492 which support it. The line would be ignored by versions earlier than 777.
493 .PP
494 .EX
495 .nf
496 #version >= 777 Q sideways\-search
497 .fi
498 .EE
499 .PP
500 These six operators are supported:
501 .RS 5m
502 .TS
503 l l.
504 > Greater than
505 < Less than
506 >= Greater than or equal to
507 <= Less than or equal to
508 = Equal to
509 != Not equal to
510 .TE
511 .RE
512 .PP
513 The #version feature is not supported in
514 .B less
515 and
516 .B lesskey
517 before version 594.
518 In those older versions, all #version lines are ignored.
519 .
520 .SH EXAMPLE
521 The following input file sets the \-i and \-S options when
522 .B less
523 is run and, on version 595 and higher, adds a \-\-color option.
524 .PP
525 .EX
526 .nf
527 #env
528 ## (Note that there must be a space at the end of the next line,
529 ## to separate the \-\-color option from the \-S option.)
530 LESS = \-i\ \-S\
531 #version\ >=\ 595\ \ LESS\ +=\ \-\-color=Hkc
532 .fi
533 .EE
534 .
535 .SH "SEE ALSO"
536 .BR less (1)
537 .
538 .SH WARNINGS
539 On MS-DOS and OS/2 systems, certain keys send a sequence of characters
540 which start with a NUL character (0).
541 This NUL character should be represented as \e340 in a lesskey file.
542 .
543 .SH COPYRIGHT
544 Copyright (C) 1984-2025 Mark Nudelman
545 .PP
546 less is part of the GNU project and is free software.
547 You can redistribute it and/or modify it
548 under the terms of either
549 (1) the GNU General Public License as published by
550 the Free Software Foundation; or (2) the Less License.
551 See the file README in the less distribution for more details
552 regarding redistribution.
553 You should have received a copy of the GNU General Public License
554 along with the source for less; see the file COPYING.
555 If not, write to the Free Software Foundation, 59 Temple Place,
556 Suite 330, Boston, MA 02111-1307, USA.
557 You should also have received a copy of the Less License;
558 see the file LICENSE.
559 .PP
560 less is distributed in the hope that it will be useful, but
561 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
562 or FITNESS FOR A PARTICULAR PURPOSE.
563 See the GNU General Public License for more details.
564 .
565 .SH AUTHOR
566 .
567 Mark Nudelman
568 .br
569 Report bugs at
570 .nh
571 https://\*:github\*:.com/\*:gwsw/\*:less/\*:issues.
572 .hy