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