-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathlesskey-bew
57 lines (47 loc) · 1.97 KB
/
lesskey-bew
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Configuration file for keys for the `less` program.
# It must be compiled with `lesskey -o ./some-output.bin -- ./this-file`
# And used like `less --lesskey ./some-output.bin ...`
# See `man lesskey` for more details.
# vim:set ft=conf:
# NOTE on how to use `noaction` to give argument to command.
# For example: There is no command that scrolls one character left or right.
# In less program, typing 1 then a key that does {left,right}-scroll would scroll by 1.
# But we can't directly set a binding for a command with an argument in lesskey file.
# To bypass this, we can set a binding to run a no-op command, then parse more keys.
# So run the `noaction` command, then parse a key sequence that runs the scroll
# command with the desired arguments.
# Ref: https://unix.stackexchange.com/a/59194/159811
#
# NOTE: A number then an action (like scroll-left) changes the action-count for the rest of the program execution.
# So to have a key that moves by 1 and a key that moves by 40, I need to change the action-count each time.
# Ref: https://github.com/gwsw/less/issues/205
# --- Define new command keys under the following line:
#command
# Use HJKL to move around by half-a-page
J forw-screen
K back-screen
H noaction 40\e(
L noaction 40\e)
# Use hjkl to move around 1-by-1
j forw-line
k back-line
# See note on how to use `noaction` like this at the top
h noaction 1\e(
l noaction 1\e)
# Disable search highlight
§ undo-hilite
# Restore help binding
\eh help
:h help
# Use Alt-q to exit and print what was currently visible
# Ref: https://github.com/gwsw/less/issues/36
\eq toggle-option -!^Predraw-on-quit\nq
# Use Alt-w to toggle long lines wrapping
# Ref: https://github.com/gwsw/less/issues/272
\ew toggle-option ^P-chop-long-lines\n
# --- Defines new line-editing keys under the following line:
#line-edit
# Escape-Escape to abort line editing
\e\e abort
# NOTE: a single \e would not work, as it would break every other keybinds using \e
# (there is no `nnoremap` a-la-vim, there's only `nmap`)