Vim-like movement in any program by using Scroll-Lock with letter keys

343 Views Asked by At

I am remapping some keys of my keyboard and want to make J, H, L and K keys behave like arrow keys when Scroll-Lock is activated, so I can use Vim-like scrolling in any program.

I am using xmodmap to remap some keys, but I couldn't have the expected behavior with scroll-lock. How can I do it?

1

There are 1 best solutions below

0
On

It's not exactly what you want, but you could write a script that toggles a hard xmodmap h,j,k,l to arrows mapping.

For example:

#!/bin/bash
if [ `cat /var/layout` == "normal" ]; then
    xmodmap -e 'keycode 43 = Left'
    ...
    echo "hjkl" > /var/layout
else
    xmodmap -e 'keycode 43 = h'
    ...
    echo "normal" > /var/layout
fi

(Use xev to find the keycodes)

Then you can call it with a global window manager hotkey. Probably all the window managers are able to do that more or less well. If you are lucky you can even bind scroll lock to it.