xref: /openbsd-src/usr.bin/less/lesskey.1 (revision 4c1e55dc91edd6e69ccc60ce855900fbc12cf34f)
1.\"	$OpenBSD: lesskey.1,v 1.9 2011/09/16 18:12:09 shadchin Exp $
2.\"
3.\" Copyright (C) 2000-2011  Mark Nudelman
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\"    notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\"    notice in the documentation and/or other materials provided with
12.\"    the distribution.
13.\"
14.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
15.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE
18.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
20.\" OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
21.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
23.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
24.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25.Dd $Mdocdate: September 16 2011 $
26.Dt LESSKEY 1
27.Os
28.Sh NAME
29.Nm lesskey
30.Nd specify key bindings for less
31.Sh SYNOPSIS
32.Nm lesskey
33.Oo Fl o Ar output
34.Pf " | " Fl -output Ns = Ns Ar output Oc
35.Op Ar input
36.Nm lesskey
37.Fl V | -version
38.Sh DESCRIPTION
39.Nm
40is used to specify a set of key bindings to be used by
41.Xr less 1 .
42The input file is a text file which describes the key bindings.
43If the input file is
44.Sq - ,
45standard input is read.
46If no input file is specified, a standard filename is used
47as the name of the input file; by default
48.Pa $HOME/.lesskey .
49.\" on MS-DOS systems, $HOME/_lesskey is used;
50.\" and on OS/2 systems $HOME/lesskey.ini is used,
51.\" or $INIT/lesskey.ini if $HOME is undefined.
52The output file is a binary file which is used by
53.Xr less 1 .
54If no output file is specified, and the environment variable
55.Ev LESSKEY
56is set, the value of
57.Ev LESSKEY
58is used as the name of the output file.
59Otherwise, a standard filename is used as the name of the output file;
60by default
61.Pa $HOME/.less
62is used.
63.\" on MS-DOS systems, $HOME/_less is used;
64.\" and on OS/2 systems, $HOME/less.ini is used,
65.\" or $INIT/less.ini if $HOME is undefined.
66If the output file already exists,
67.Nm
68will overwrite it.
69.Pp
70A system-wide lesskey file may also be set up to provide key bindings.
71If a key is defined in both a local lesskey file and in the
72system-wide file, key bindings in the local file take precedence over
73those in the system-wide file.
74If the environment variable
75.Ev LESSKEY_SYSTEM
76is set,
77.Xr less 1
78uses that as the name of the system-wide lesskey file.
79Otherwise,
80.Xr less 1
81looks in a standard place for the system-wide lesskey file:
82On
83.Ox ,
84the system-wide lesskey file is
85.Pa /etc/sysless .
86.Pp
87The
88.Fl V
89or
90.Fl -version
91option causes
92.Nm
93to print its version number and immediately exit.
94If
95.Fl V
96or
97.Fl -version
98is present, other options and arguments are ignored.
99.Pp
100The input file consists of one or more sections.
101Each section starts with a line that identifies the type of section.
102Possible sections are:
103.Bl -tag -width "#line-edit" -offset indent
104.It #command
105Defines new command keys.
106.It #line-edit
107Defines new line-editing keys.
108.It #env
109Defines environment variables.
110.El
111.Pp
112Blank lines and lines which start with a pound sign (#) are ignored,
113except for the special section header lines.
114.Sh COMMAND SECTION
115The command section begins with the line
116.Pp
117.Dl #command
118.Pp
119If the command section is the first section in the file,
120this line may be omitted.
121The command section consists of lines of the form:
122.Bd -filled -offset indent
123.Ar string
124.Aq whitespace
125.Ar action
126.Bq extra-string
127.Aq newline
128.Ed
129.Pp
130Whitespace is any sequence of one or more spaces and/or tabs.
131The
132.Ar string
133is the command key(s) which invoke the action.
134The
135.Ar string
136may be a single command key, or a sequence of up to 15 keys.
137The
138.Ar action
139is the name of the less action, from the list below.
140The characters in the
141.Ar string
142may appear literally, or be prefixed by a caret to indicate a control key.
143A backslash followed by one to three octal digits may be used to
144specify a character by its octal value.
145A backslash followed by certain characters specifies input
146characters as follows:
147.Pp
148.Bl -tag -width Ds -offset indent -compact
149.It \eb
150BACKSPACE
151.It \ee
152ESCAPE
153.It \en
154NEWLINE
155.It \er
156RETURN
157.It \et
158TAB
159.It \eku
160UP ARROW
161.It \ekd
162DOWN ARROW
163.It \ekr
164RIGHT ARROW
165.It \ekl
166LEFT ARROW
167.It \ekU
168PAGE UP
169.It \ekD
170PAGE DOWN
171.It \ekh
172HOME
173.It \eke
174END
175.It \ekx
176DELETE
177.El
178.Pp
179A backslash followed by any other character indicates that character is
180to be taken literally.
181Characters which must be preceded by backslash include
182caret, space, tab and the backslash itself.
183.Pp
184An action may be followed by an
185.Qq extra
186string.
187When such a command is entered while running less,
188the action is performed, and then the extra
189string is parsed, just as if it were typed in to less.
190This feature can be used in certain cases to extend
191the functionality of a command.
192For example, see the
193.Sq {
194and
195.Sq :t
196commands in the example below.
197The extra string has a special meaning for the
198.Qq quit
199action:
200when less quits,
201first character of the extra string is used as its exit status.
202.Pp
203The following input file describes the set of
204default command keys used by less:
205.Bd -literal -offset indent
206#command
207\er	forw-line
208\en	forw-line
209e	forw-line
210j	forw-line
211\ekd	forw-line
212^E	forw-line
213^N	forw-line
214k	back-line
215y	back-line
216^Y	back-line
217^K	back-line
218^P	back-line
219J	forw-line-force
220K	back-line-force
221Y	back-line-force
222d	forw-scroll
223^D	forw-scroll
224u	back-scroll
225^U	back-scroll
226\e40	forw-screen
227f	forw-screen
228^F	forw-screen
229^V	forw-screen
230\ekD	forw-screen
231b	back-screen
232^B	back-screen
233\eev	back-screen
234\ekU	back-screen
235z	forw-window
236w	back-window
237\ee\e40	forw-screen-force
238F	forw-forever
239R	repaint-flush
240r	repaint
241^R	repaint
242^L	repaint
243\eeu	undo-hilite
244g	goto-line
245\ekh	goto-line
246<	goto-line
247\ee<	goto-line
248p	percent
249%	percent
250\ee[	left-scroll
251\ee]	right-scroll
252\ee(	left-scroll
253\ee)	right-scroll
254{	forw-bracket {}
255}	back-bracket {}
256(	forw-bracket ()
257)	back-bracket ()
258[	forw-bracket []
259]	back-bracket []
260\ee^F	forw-bracket
261\ee^B	back-bracket
262G	goto-end
263\ee>	goto-end
264>	goto-end
265\eke	goto-end
266=	status
267^G	status
268:f	status
269/	forw-search
270?	back-search
271\ee/	forw-search *
272\ee?	back-search *
273n	repeat-search
274\een	repeat-search-all
275N	reverse-search
276\eeN	reverse-search-all
277&	filter
278m	set-mark
279\'	goto-mark
280^X^X	goto-mark
281E	examine
282:e	examine
283^X^V	examine
284:n	next-file
285:p	prev-file
286t	next-tag
287T	prev-tag
288:x	index-file
289:d	remove-file
290-	toggle-option
291:t	toggle-option t
292s	toggle-option o
293_	display-option
294|	pipe
295v	visual
296!	shell
297+	firstcmd
298H	help
299h	help
300V	version
3010	digit
3021	digit
3032	digit
3043	digit
3054	digit
3065	digit
3076	digit
3087	digit
3098	digit
3109	digit
311q	quit
312Q	quit
313:q	quit
314:Q	quit
315ZZ	quit
316.Ed
317.Sh PRECEDENCE
318Commands specified by
319.Nm
320take precedence over the default commands.
321A default command key may be disabled by including it in the
322input file with the action
323.Qq invalid .
324Alternatively, a key may be defined
325to do nothing by using the action
326.Qq noaction .
327.Qq noaction
328is similar to
329.Qq invalid ,
330but less will give an error beep for an
331.Qq invalid
332command, but not for a
333.Qq noaction
334command.
335In addition, ALL default commands may be disabled by
336adding this control line to the input file:
337.Pp
338.Dl #stop
339.Pp
340This will cause all default commands to be ignored.
341The #stop line should be the last line in that section of the file.
342.Pp
343Be aware that #stop can be dangerous.
344Since all default commands are disabled, you must provide sufficient
345commands before the #stop line to enable all necessary actions.
346For example, failure to provide a
347.Qq quit
348command can lead to frustration.
349.Sh LINE EDITING SECTION
350The line-editing section begins with the line:
351.Pp
352.Dl #line-edit
353.Pp
354This section specifies new key bindings for the line editing commands,
355in a manner similar to the way key bindings for
356ordinary commands are specified in the #command section.
357The line-editing section consists of a list of keys and actions,
358one per line as in the example below.
359.Pp
360The following input file describes the set of
361default line-editing keys used by less:
362.Bd -literal -offset indent
363#line-edit
364\et	forw-complete
365\e17	back-complete
366\ee\et	back-complete
367^L	expand
368^V	literal
369^A	literal
370\eel	right
371\ekr	right
372\eeh	left
373\ekl	left
374\eeb	word-left
375\ee\ekl	word-left
376\eew	word-right
377\ee\ekr	word-right
378\eei	insert
379\eex	delete
380\ekx	delete
381\eeX	word-delete
382\eekx	word-delete
383\ee\eb	word-backspace
384\ee0	home
385\ekh	home
386\ee$	end
387\eke	end
388\eek	up
389\eku	up
390\eej	down
391^G	abort
392.Ed
393.Sh ENVIRONMENT SECTION
394The environment variable section begins with the line
395.Pp
396.Dl #env
397.Pp
398Following this line is a list of environment variable assignments.
399Each line consists of an environment variable name, an equals sign
400.Pq Sq =
401and the value to be assigned to the environment variable.
402Whitespace before and after the equals sign is ignored.
403Variables assigned in this way are visible only to less.
404If environment variables are defined in more than one place,
405variables defined in a local lesskey file take precedence over
406variables defined in the system environment, which take precedence
407over variables defined in the system-wide lesskey file.
408Although the lesskey file can be used to override variables set in the
409environment, the main purpose of assigning variables in the lesskey file
410is simply to have all less configuration information stored in one file.
411.Pp
412The following input file sets the -i option whenever less is run,
413and specifies the character set to be
414.Qq latin1 :
415.Bd -literal -offset indent
416#env
417LESS = -i
418LESSCHARSET = latin1
419.Ed
420.Sh ENVIRONMENT
421.Bl -tag -width LESSKEY_SYSTEM -compact
422.It Ev LESSKEY
423Name of the default
424.Nm
425file.
426.It Ev LESSKEY_SYSTEM
427Name of the default system-wide
428.Nm
429file.
430.El
431.Sh FILES
432.Bl -tag -width "$HOME/.lesskey" -compact
433.It $HOME/.less
434Default
435.Nm
436file.
437.It $HOME/.lesskey
438Default
439.Nm
440input file.
441.It /etc/sysless
442Default system-wide
443.Nm
444file.
445.El
446.Sh SEE ALSO
447.Xr less 1
448.Sh AUTHORS
449.An Mark Nudelman Aq markn@greenwoodsoftware.com
450.Pp
451Send bug reports or comments to the above address or to
452.Aq bug\-less@gnu.org .
453.\" .Sh CAVEATS
454.\" On MS-DOS and OS/2 systems, certain keys send a sequence of characters
455.\" which start with a NUL character (0).
456.\" This NUL character should be represented as \e340 in a lesskey file.
457