Debian Codegraph @

upstream/opensuse-tumbleweed/man1/lesskey.1

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