Configure Caps Lock as AltGr and Arrows like in vim
Solution 1:
1. add a new XKB partial file
sudo vi /usr/share/X11/xkb/symbols/altgr_vim
with this content:
partial keypad_keys
xkb_symbols "altgr-vim" {
# replace Caps with AltGr
key <CAPS> { [ ISO_Level3_Shift ] };
# Add vim cursor keys to be accessed with AltGr
key <AB02> { [ x, X, Delete, Delete ] };
key <AC02> { [ s, S, KP_Enter, KP_Enter ] };
key <AC03> { [ d, D, Next, Next ] };
key <AC04> { [ f, F, BackSpace, BackSpace ] };
key <AC06> { [ h, H , Left, Left ] };
key <AC07> { [ j, J, Down, Down ] };
key <AC08> { [ k, K, Up, Up ] };
key <AC09> { [ l, L, Right, Right ] };
key <AD07> { [ u, U, Prior, Prior ] };
key <AE03> { [ 3, section, Home, Home ] };
key <AE04> { [ 4, dollar, End, End ] };
};
2. include the partial in your language file
for example for german it is /usr/share/X11/xkb/symbols/de
(where /de
is your language) add this inside the first block (xkb_symbols "basic"
):
include "altgr_vim(altgr-vim)"
Note: This part has to be repeated after every distribution update
3. reload the window session
Press ALT+F2, enter "r" to reload the gnome session or just log out and in again. Now the new key compositions will be available
4. solve some problems
-
Some applications don't accept the settings, for example:
sublime
which can be replaced byatom
. -
Some applications need extra settings, e.g. in
yakuake
the key-bindings are set to "XFree 4", if you set them to "Linux" or "Solaris", then the XKB settings works there also:
remaining problems:
- some apps still don't accept those settings
- after an upgrade, where the symbols file is updated, you have to repeat step 2