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