The less manpage says you can use CtrlLeft and CtrlRight to move the cursor by one word when performing line editing (e.g. entering a search string):

     (That is, CONTROL and LEFTARROW simultaneously.)  Move the
     cursor one word to the left.

When I try this, it instead enters the printed representation of the control sequence my terminal sent. CtrlLeft enters ESC[1;5D and Ctrl-Right enters ESC[1;5C.

My terminal is configured to send ^[[1;5D and ^[[1;5C for CtrlLeft and CtrlRight, respectively, and I put this in my ~/.inputrc so Readline would perform word-wise jumps when I'm in the shell (Bash),

# Ctrl-Left
"\033[1;5D": backward-word
# Ctrl-Right
"\033[1;5C": forward-word

Presumably less is expecting some different control sequence? I'm a little hesitant to change the escape sequences my terminal is sending just to satisfy less, for fear it would trip up Vim or Readline, but I'm willing to give it a shot.


Configure less's key bindings so that the sequence \e[1;5D runs word-left and \e[1;5C runs `word-right.

In the file ~/.lesskey, add

\e[1;5D    word-left
\e[1;5C    word-right

If there is already a #line-edit section, add the requisite lines.

Then run lesskey. This companion program transforms ~/.lesskey (in human-readable syntax) into the binary format ~/.less that less uses.

  • Slight correction: at least on my version of Less, I had to put these bindings in the line-edit section (rather than command), or lesskey would complain. – ivan Jun 21 '17 at 2:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.