如何以较少的费用设置hjkl?


9

less已经使用j / k进行垂直滚动,但不使用h / l进行水平滚动(在--ch模式下)。l键无论如何都没有绑定,并且h只是H的同义词,因此我不会覆盖任何重要的绑定。

如何使h和l水平滚动?


3
请参阅man lesskey
Marco

Answers:


6

man less 告诉我们以下内容:

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".

它告诉我们使用lesskey生成一个lesskey文件读取man lesskey详细信息。您可以将以下内容放入lesskey输入文件中(~/.lesskey默认情况下)

h left-scroll
l right-scroll

然后运行lesskey,它将~/.less为您生成一个输出文件(默认情况下)。

据我所知,您不能逐字符水平滚动。


2

您可以使用该lesskey程序设置自己的键绑定。.lesskey在主目录中创建一个包含键绑定的文件,然后运行lesskey命令将其转换为less可理解的格式(已编译的绑定存储在中~/.less)。

没有命令向左或向右滚动一个字符。您可以通过将数字参数1传递给left-scrolland right-scroll命令来实现。您不能直接为带有参数的命令设置绑定,但是可以设置绑定以运行命令,然后解析更多键。因此,运行noaction命令,然后解析一个键序列,该键序列将使用所需的参数运行scroll命令。

h noaction 1\e(
l noaction 1\e)
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.