Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 460
Seninha Avatar asked Jul 03 '14 18:07

Seninha


People also ask

What programs use Scroll Lock?

Today, this particular use of Scroll Lock is rare. Modern programs honoring this behavior include IBM Lotus Notes, Forté Agent, Image-Line FL Studio, Renoise, Microsoft Excel, Microsoft Project, LibreOffice Calc, and occasionally Microsoft Word.

What are Scroll Lock keys?

The Scroll Lock key, which is a relic of the early IBM PC keyboard, is a key on your keyboard created to lock all scrolling methods. Scroll Lock was designed to alter the functionality of the arrow keys of the keyboard.

Can you scroll in Vim?

You can make Vim scroll the text using the shifted up/down arrows by mapping Shift-Up to Ctrl-Y and Shift-Down to Ctrl-E. Shift-Down will then scroll down (like moving a scroll-bar down, or like moving a cursor at the bottom of a window down), and Shift-Up will then scroll up (like moving a scroll-bar up, etc).


1 Answers

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.

like image 92
johannes_lalala Avatar answered Oct 12 '22 23:10

johannes_lalala