]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/less/lesskey.nro
Merge llvm-project main llvmorg-15-init-17485-ga3e38b4a206b
[FreeBSD/FreeBSD.git] / contrib / less / lesskey.nro
1 '\" t
2 .TH LESSKEY 1 "Version 608: 22 Jul 2022"
3 .SH NAME
4 lesskey \- customize key bindings for less
5 .SH "SYNOPSIS (deprecated)"
6 .B "lesskey [\-o output] [\-\-] [input]"
7 .br
8 .B "lesskey [\-\-output=output] [\-\-] [input]"
9 .br
10 .B "lesskey \-V"
11 .br
12 .B "lesskey \-\-version"
13 .SH SCOPE
14 This document describes the format of the 
15 .I lesskey
16 source file, which is used by
17 .I less
18 version 582 and later.
19 In previous versions of 
20 .IR less ,
21 a separate program called
22 .I lesskey
23 was used to compile the 
24 .I lesskey 
25 source file into a format understood by
26 .IR less .
27 This compilation step is no longer required and the
28 .I lesskey
29 program is therefore deprecated, although the file format remains supported by
30 .I less
31 itself.
32 .PP
33 .SH DESCRIPTION
34 A
35 .I lesskey
36 file specifies a set of key bindings and environment variables
37 to be used by subsequent invocations of
38 .I less.
39 .SH FILE FORMAT
40 The input file consists of one or more
41 .I sections.
42 Each section starts with a line that identifies the type of section.
43 Possible sections are:
44 .IP #command
45 Customizes command key bindings.
46 .IP #line-edit
47 Customizes line-editing key bindings.
48 .IP #env
49 Defines environment variables.
50 .PP
51 Blank lines and lines which start with a pound sign (#) are ignored,
52 except as noted below.
53 .
54 .SH "COMMAND SECTION"
55 The command section begins with the line
56 .sp
57 #command
58 .sp
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:
62 .sp
63         \fIstring\fP <whitespace> \fIaction\fP [extra-string] <newline>
64 .sp
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:
75 .RS 5m
76 .TS
77 l l l.
78 \eb     BACKSPACE       (0x08)
79 \ee     ESCAPE  (0x1B)
80 \en     NEWLINE (0x0A)
81 \er     RETURN  (0x0D)
82 \et     TAB     (0x09)
83 .TE
84 .sp
85 \ek followed by a single character represents the char(s) produced when one of these keys is pressed:
86 .TS
87 l l.
88 \ekb    BACKSPACE (the BACKSPACE key)
89 \ekB    ctrl-BACKSPACE
90 \ekd    DOWN ARROW
91 \ekD    PAGE DOWN
92 \eke    END
93 \ekh    HOME
94 \eki    INSERT
95 \ekl    LEFT ARROW
96 \ekL    ctrl-LEFT ARROW
97 \ekr    RIGHT ARROW
98 \ekR    ctrl-RIGHT ARROW
99 \ekt    BACKTAB
100 \eku    UP ARROW
101 \ekU    PAGE UP
102 \ekx    DELETE
103 \ekX    ctrl-DELETE
104 \ek1    F1
105 .TE
106
107 .PP
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.
112 .PP
113 An action may be followed by an "extra" string.
114 When such a command is entered while running
115 .IR less ,
116 the action is performed, and then the extra
117 string is parsed, just as if it were typed in to
118 .IR less .
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:
123 when
124 .I less
125 quits, the first character of the extra string is used as its exit status.
126 .
127 .SH EXAMPLE
128 The following input file describes the set of
129 default command keys used by 
130 .IR less .
131 Documentation on each command can be found in the
132 .less
133 man page, under the key sequence which invokes the command.
134 .sp
135 .RS 5m
136 .TS
137 l l.
138 #command
139 \er     forw-line
140 \en     forw-line
141 e       forw-line
142 j       forw-line
143 \ekd    forw-line
144 ^E      forw-line
145 ^N      forw-line
146 k       back-line
147 y       back-line
148 ^Y      back-line
149 ^K      back-line
150 ^P      back-line
151 J       forw-line-force
152 K       back-line-force
153 Y       back-line-force
154 d       forw-scroll
155 ^D      forw-scroll
156 u       back-scroll
157 ^U      back-scroll
158 \e40    forw-screen
159 f       forw-screen
160 ^F      forw-screen
161 ^V      forw-screen
162 \ekD    forw-screen
163 b       back-screen
164 ^B      back-screen
165 \eev    back-screen
166 \ekU    back-screen
167 z       forw-window
168 w       back-window
169 \ee\e40 forw-screen-force
170 F       forw-forever
171 \eeF    forw-until-hilite
172 R       repaint-flush
173 r       repaint
174 ^R      repaint
175 ^L      repaint
176 \eeu    undo-hilite
177 \eeU    clear-search
178 g       goto-line
179 \ekh    goto-line
180 <       goto-line
181 \ee<    goto-line
182 p       percent
183 %       percent
184 \ee[    left-scroll
185 \ee]    right-scroll
186 \ee(    left-scroll
187 \ee)    right-scroll
188 \ekl    left-scroll
189 \ekr    right-scroll
190 \ee{    no-scroll
191 \ee}    end-scroll
192 {       forw-bracket {}
193 }       back-bracket {}
194 (       forw-bracket ()
195 )       back-bracket ()
196 [       forw-bracket []
197 ]       back-bracket []
198 \ee^F   forw-bracket
199 \ee^B   back-bracket
200 G       goto-end
201 \ee>    goto-end
202 >       goto-end
203 \eke    goto-end
204 \eeG    goto-end-buffered
205 \&=     status
206 ^G      status
207 :f      status
208 /       forw-search
209 ?       back-search
210 \ee/    forw-search *
211 \ee?    back-search *
212 n       repeat-search
213 \een    repeat-search-all
214 N       reverse-search
215 \eeN    reverse-search-all
216 &       filter
217 m       set-mark
218 M       set-mark-bottom
219 \eem    clear-mark
220 '       goto-mark
221 ^X^X    goto-mark
222 E       examine
223 :e      examine
224 ^X^V    examine
225 :n      next-file
226 :p      prev-file
227 t       next-tag
228 T       prev-tag
229 :x      index-file
230 :d      remove-file
231 -       toggle-option
232 :t      toggle-option t
233 s       toggle-option o
234         ## Use a long option name by starting the extra string with ONE dash; eg:
235         ##   s toggle-option -log-file\n
236 \&_     display-option
237 |       pipe
238 v       visual
239 !       shell
240 +       firstcmd
241 H       help
242 h       help
243 V       version
244 0       digit
245 1       digit
246 2       digit
247 3       digit
248 4       digit
249 5       digit
250 6       digit
251 7       digit
252 8       digit
253 9       digit
254 q       quit
255 Q       quit
256 :q      quit
257 :Q      quit
258 ZZ      quit
259 .TE
260 .RE
261 .sp
262 .SH PRECEDENCE
263 Commands specified by
264 .I lesskey
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
271 .I less
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:
276 .sp
277 #stop
278 .sp
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.
281 .PP
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.
287 .
288 .SH "LINE EDITING SECTION"
289 The line-editing section begins with the line:
290 .sp
291 #line-edit
292 .sp
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.
298 .
299 .SH EXAMPLE
300 The following input file describes the set of
301 default line-editing keys used by
302 .IR less :
303 .sp
304 .RS 5m
305 .TS
306 l l.
307 #line-edit
308 \et     forw-complete
309 \e17    back-complete
310 \ee\et  back-complete
311 ^L      expand
312 ^V      literal
313 ^A      literal
314 \eel    right
315 \ekr    right
316 \eeh    left
317 \ekl    left
318 \eeb    word-left
319 \ee\ekl word-left
320 \eew    word-right
321 \ee\ekr word-right
322 \eei    insert
323 \eex    delete
324 \ekx    delete
325 \eeX    word-delete
326 \eekx   word-delete
327 \ee\eb  word-backspace
328 \ee0    home
329 \ekh    home
330 \ee$    end
331 \eke    end
332 \eek    up
333 \eku    up
334 \eej    down
335 ^G      abort
336 .TE
337 .RE
338 .sp
339 .
340 .SH "LESS ENVIRONMENT VARIABLES"
341 The environment variable section begins with the line
342 .sp
343 #env
344 .sp
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
350 .IR less .
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.
353 .
354 .sp
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.
362 .
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
366 .I less
367 (or
368 .IR lesskey )
369 matches the operator.
370 This can be helpful if a lesskey file is used by different versions of
371 .IR less .
372 .sp
373 For example, suppose that a new command named 'sideways-search' is added in 
374 .I less
375 version 777.
376 Then the following line would assign the command to the Q key, but only in versions of
377 .I less
378 which support it. The line would be ignored by versions earlier than 777.
379 .sp
380 .nf
381         #version >= 777  Q sideways-search
382 .fi
383 .sp
384 These six operators are supported:
385 .RS 5m
386 .TS
387 l l.
388  >      Greater than
389  <      Less than
390  >=     Greater than or equal to
391  <=     Less than or equal to
392  =      Equal to
393  !=     Not equal to
394 .TE
395 .RE
396 .sp
397 The #version feature is not supported in
398 .I less
399 and
400 .I lesskey
401 before version 594.
402 In those older versions, all #version lines are ignored.
403 .
404 .SH EXAMPLE
405 The following input file sets the \-i and \-S options when
406 .less
407 is run and, on version 595 and higher, adds a \-\-color option.
408 .sp
409 .nf
410         #env
411         LESS = \-i\ \-S
412         #version\ >=\ 595\ \ LESS\ +=\ \-\-color=Hkc
413 .fi
414 .
415 .SH "SEE ALSO"
416 .BR less (1)
417 .
418 .SH WARNINGS
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.
422 .
423 .SH COPYRIGHT
424 Copyright (C) 1984-2022  Mark Nudelman
425 .PP
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.
439 .PP
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.
444 .
445 .SH AUTHOR
446 .
447 Mark Nudelman
448 .br
449 Report bugs at https://github.com/gwsw/less/issues.