According to the manpage for lesskey, the following keys are bound to left-scroll and right-scroll:

\e[       left-scroll
\e]       right-scroll
\e(       left-scroll
\e)       right-scroll
\kl       left-scroll
\kr       right-scroll

The arrow keys and Esc-( / Esc -) work fine, as does Esc-] for scroll-right, but Esc-[ does not work for scroll-left. Instead, it just shows this in the command line prompt:


Adding this line to ~/.lesskey functions as a workaround:

\e[ left-scroll

But why doesn't it work by default?

I have observed this behavior in XFCE4 on Debian stretch as well as Kubuntu 18.04, as well as a variety of terminal emulators.

$ less --version
less 487 (GNU regular expressions)
Copyright (C) 1984-2016  Mark Nudelman

less comes with NO WARRANTY, to the extent permitted by law.
For information about the terms of redistribution,
see the file named README in the less distribution.
Homepage: http://www.greenwoodsoftware.com/less

I considered filing a bug report, but the list of known bugs and feature requests suggests that it is a known behavior:

Enhancement requests

[ . . . ]

Ref number: 175

Implemented in version: 322

Add alternate command for ESC-[.

Is this actually a limitation in less, or is it a quirk in how terminals handle the Escape key?

1 Answer 1


It's because ESC [ also happens to be the start of the sequence of characters sent by several function keys on some terminals, such as Home or End or PageUp... Those are also bound to some action in less.

So when less receives a ESC [, it's waiting for more (without timing out like some other applications do).

On my terminal ESC[6~ is PageDown. If I press Alt+[, I see ESC [ like you do. But then I can enter 6 and ~ and that does scroll down.

If you run TERM=vt100 less instead of less, where the vt100 terminfo page doesn't have any entry for Home or End... you see ESC [ works.

If however, you add \e[ left-scroll to your ~/.lesskey (and run lesskey to compile it into ~/.less), you'll notice the ESC [ works to scroll left, but all the Home, PageUP... stop working, they all scroll left and the extra characters they send cause some beeping.

Looking at the code, it's all about the order the table of commands are processed. The ~/.less command table is added last, but inserted at the head, so its entries are processed before the builtin ones.

Upon a ESC [ input, if the entry for \e[ left-scroll is found first, it is processed, if the one for \kD forw-screen (which on many terminals translates to \e[6~ forw-screen) is found first, then it's only a prefix match, and less waits for more input.

So, it is kind of a bug. The fix would be to add a timeout. Adding a short timeout would however mean giving up on multi-key commands; a long timeout to give enough time for a user to enter a multi-key command would probably make ESC [ too unresponsive.

Now, terminals that have PageUp, etc, would also generally have Left and Right key which are also bound to left-scroll, right-scroll, so you may want to use that instead for scrolling.

  • Interesting. But if it's on the terminal side, why does binding \e[ left-scroll in lesskey change things? Nov 27, 2019 at 22:10
  • @NathanielM.Beaver, good point, I missed that part. See the edit for the details. Nov 28, 2019 at 7:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .