4

I'd like to swap RETURN (scroll forward N lines, default one window) and SPACE (scroll forward N lines, default 1) in less to get a for me more natural way to page through man pages.

I saw years ago a colleague having this setup during a telnet session to a router while he was skimming through a config file, so I don't actually know if this setting was on his SSH client, on the node or wherever.

Anyway, I'd like to achieve this to the most extent possible, be it locally or remotely.

I checked less man page's key bindings section and found a reference to lesskey.

Unfortunately, Darwin doesn't have this program.

2
  • Suggest migration to Ask Different. Commented Sep 13, 2015 at 15:06
  • What is "more natural"? Usually less scrolls one line when hitting enter, and one screen when hitting the spacebar. Commented Jun 22, 2022 at 8:04

2 Answers 2

2

You could install less via MacPorts or homebrew (or Fink!?), MacPorts at least has a lesskey containing less package:

% sudo port install less
...
% rehash
% which lesskey
/opt/local/bin/lesskey
% 

This would then require PATH changes or a function for less so the ports-installed version of less gets picked up before the OS one, e.g.

function less {
  /opt/local/bin/less "$@"
}
1
  • I'll consider it, but I thought there might be a broader solution, like modifying the term file — still searching… Commented Sep 13, 2015 at 16:05
2

Since Darwin lacks lesskey (see here and here) I installed less 458 via MacPorts and added the bindings using the defaults path for my system. lesskey will take $HOME/.lesskey and output $HOME/.less. You can also use LESSKEY or LESSKEY_SYSTEM.

~ $ vi .lesskey
#command
\n        forw-screen
\40       forw-line
~ $ lesskey
~ $ ls -d .less*
.less       .lesshst    .lesskey

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.