2 .TH LESSKEY 1 "Version 608: 22 Jul 2022"
4 lesskey \- customize key bindings for less
5 .SH "SYNOPSIS (deprecated)"
6 .B "lesskey [\-o output] [\-\-] [input]"
8 .B "lesskey [\-\-output=output] [\-\-] [input]"
12 .B "lesskey \-\-version"
14 This document describes the format of the
16 source file, which is used by
18 version 582 and later.
19 In previous versions of
21 a separate program called
23 was used to compile the
25 source file into a format understood by
27 This compilation step is no longer required and the
29 program is therefore deprecated, although the file format remains supported by
36 file specifies a set of key bindings and environment variables
37 to be used by subsequent invocations of
40 The input file consists of one or more
42 Each section starts with a line that identifies the type of section.
43 Possible sections are:
45 Customizes command key bindings.
47 Customizes line-editing key bindings.
49 Defines environment variables.
51 Blank lines and lines which start with a pound sign (#) are ignored,
52 except as noted below.
55 The command section begins with the line
59 If the command section is the first section in the file,
60 this line may be omitted.
61 The command section consists of lines of the form:
63 \fIstring\fP <whitespace> \fIaction\fP [extra-string] <newline>
65 Whitespace is any sequence of one or more spaces and/or tabs.
66 The \fIstring\fP is the command key(s) which invoke the action.
67 The \fIstring\fP may be a single command key, or a sequence of up to 15 keys.
68 The \fIaction\fP is the name of the less action, from the list below.
69 The characters in the \fIstring\fP may appear literally, or be
70 prefixed by a caret to indicate a control key.
71 A backslash followed by one to three octal digits may be used to
72 specify a character by its octal value.
73 A backslash followed by certain characters specifies input
74 characters as follows:
85 \ek followed by a single character represents the char(s) produced when one of these keys is pressed:
88 \ekb BACKSPACE (the BACKSPACE key)
108 A backslash followed by any other character indicates that character is
109 to be taken literally.
110 Characters which must be preceded by backslash include
111 caret, space, tab and the backslash itself.
113 An action may be followed by an "extra" string.
114 When such a command is entered while running
116 the action is performed, and then the extra
117 string is parsed, just as if it were typed in to
119 This feature can be used in certain cases to extend
120 the functionality of a command.
121 For example, see the "{" and ":t" commands in the example below.
122 The extra string has a special meaning for the "quit" action:
125 quits, the first character of the extra string is used as its exit status.
128 The following input file describes the set of
129 default command keys used by
131 Documentation on each command can be found in the
133 man page, under the key sequence which invokes the command.
169 \ee\e40 forw-screen-force
171 \eeF forw-until-hilite
204 \eeG goto-end-buffered
213 \een repeat-search-all
215 \eeN reverse-search-all
234 ## Use a long option name by starting the extra string with ONE dash; eg:
235 ## s toggle-option -log-file\n
263 Commands specified by
265 take precedence over the default commands.
266 A default command key may be disabled by including it in the
267 input file with the action "invalid".
268 Alternatively, a key may be defined
269 to do nothing by using the action "noaction".
270 "noaction" is similar to "invalid", but
272 will give an error beep for an "invalid" command,
273 but not for a "noaction" command.
274 In addition, ALL default commands may be disabled by
275 adding this control line to the input file:
279 This will cause all default commands to be ignored.
280 The #stop line should be the last line in that section of the file.
282 Be aware that #stop can be dangerous.
283 Since all default commands are disabled,
284 you must provide sufficient commands before the #stop line
285 to enable all necessary actions.
286 For example, failure to provide a "quit" command can lead to frustration.
288 .SH "LINE EDITING SECTION"
289 The line-editing section begins with the line:
293 This section specifies new key bindings for the line editing commands,
294 in a manner similar to the way key bindings for
295 ordinary commands are specified in the #command section.
296 The line-editing section consists of a list of keys and actions,
297 one per line as in the example below.
300 The following input file describes the set of
301 default line-editing keys used by
327 \ee\eb word-backspace
340 .SH "LESS ENVIRONMENT VARIABLES"
341 The environment variable section begins with the line
345 Following this line is a list of environment variable assignments.
346 Each line consists of an environment variable name, an equals sign (=)
347 and the value to be assigned to the environment variable.
348 White space before and after the equals sign is ignored.
349 Variables assigned in this way are visible only to
351 If a variable is specified in the system environment and also in a
352 lesskey file, the value in the lesskey file takes precedence.
355 If the variable name is followed by += rather than =,
356 the string is appended to the variable's existing value.
357 This currently works only if any += lines immediately follow
358 the same variable's original definition (with an = line),
359 without any intervening definitions of other variables.
360 It can append only to a variable defined earlier in the file;
361 it cannot append to a variable in the system environment.
363 .SH CONDITIONAL CONFIGURATION
364 If a line begins with #version followed by a relational operator and a version number,
365 the remainder of the line is parsed if and only if the running version of
369 matches the operator.
370 This can be helpful if a lesskey file is used by different versions of
373 For example, suppose that a new command named 'sideways-search' is added in
376 Then the following line would assign the command to the Q key, but only in versions of
378 which support it. The line would be ignored by versions earlier than 777.
381 #version >= 777 Q sideways-search
384 These six operators are supported:
390 >= Greater than or equal to
391 <= Less than or equal to
397 The #version feature is not supported in
402 In those older versions, all #version lines are ignored.
405 The following input file sets the \-i and \-S options when
407 is run and, on version 595 and higher, adds a \-\-color option.
412 #version\ >=\ 595\ \ LESS\ +=\ \-\-color=Hkc
419 On MS-DOS and OS/2 systems, certain keys send a sequence of characters
420 which start with a NUL character (0).
421 This NUL character should be represented as \e340 in a lesskey file.
424 Copyright (C) 1984-2022 Mark Nudelman
426 less is part of the GNU project and is free software.
427 You can redistribute it and/or modify it
428 under the terms of either
429 (1) the GNU General Public License as published by
430 the Free Software Foundation; or (2) the Less License.
431 See the file README in the less distribution for more details
432 regarding redistribution.
433 You should have received a copy of the GNU General Public License
434 along with the source for less; see the file COPYING.
435 If not, write to the Free Software Foundation, 59 Temple Place,
436 Suite 330, Boston, MA 02111-1307, USA.
437 You should also have received a copy of the Less License;
438 see the file LICENSE.
440 less is distributed in the hope that it will be useful, but
441 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
442 or FITNESS FOR A PARTICULAR PURPOSE.
443 See the GNU General Public License for more details.
449 Report bugs at https://github.com/gwsw/less/issues.