3

When I press h in less pager, it displays a help screen. For a seasoned vim/less user, this behavior is extremely annoying. How can I disable the h key for showing the help screen in less?

>>> /bin/less --version
less 458 (POSIX regular expressions)
Copyright (C) 1984-2012 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
4

I believe you can use a lesskey file to change the key bindings and more h and H somewhere more to your liking. From the manual:

KEY BINDINGS

You may define your own less commands by using the program lesskey (1) to create a lesskey file. This file specifies a set of command keys and an action associated with each key. You may also use lesskey to change the line-editing keys (see LINE EDITING), and to set environment variables. If the environment variable LESSKEY is set, less uses that as the name of the lesskey file. Otherwise, less looks in a standard place for the lesskey file: On Unix systems, less looks for a lesskey file called $HOME/.less. On MS-DOS and Windows systems, less looks for a lesskey file called $HOME/_less, and if it is not found there, then looks for a lesskey file called _less in any directory specified in the PATH environment variable. On OS/2 systems, less looks for a lesskey file called $HOME/less.ini, and if it is not found, then looks for a lesskey file called less.ini in any directory specified in the INIT environment variable, and if it [is] not found there, then looks for a lesskey file called less.ini in any directory specified in the PATH environment variable. See the lesskey manual page for more details.

A system-wide lesskey file may also be set up to provide key bindings. If a key is defined in both a local lesskey file and in the system-wide file, key bindings in the local file take precedence over those in the system-wide file. If the environment variable LESSKEY_SYSTEM is set, less uses that as the name of the system-wide lesskey file. Otherwise, less looks in a standard place for the system-wide lesskey file: On Unix systems, the system-wide lesskey file is /usr/local/etc/sysless. (However, if less was built with a different sysconf directory than /usr/local/etc, that directory is where the sysless file is found.) On MS-DOS and Windows systems, the system-wide lesskey file is c:\_sysless. On OS/2 systems, the system-wide lesskey file is c:\sysless.ini.

0

You may be interested in a program called vimpager.

You may also be interested in this very similar question on the Super User Stack Exchange: How to use my vim configuration in less?, which describes vimpager and other solutions you might like.

Since you want regular vim keybindings, you'll want to use the let g:less.enabled = 0 setting in your .vimrc or .vimpagerrc. Otherwise, it will use less bindings!

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.