SweVi is a keyboard layout that removes for programmers and other vi-users often unnecessary keys and replaces them with move useful ones.
The layout replaces the Caps Lock key with AltGr to allow for a more easily accessible third layer on the keyboard. It also adds additional keys for <, > and | and removes dead keys, keys that are pressed once and then wait for another keypress before anything happens. For example, to write a ~ on the normal Swedish keyboard layout, you have to press AltGr+(~-key)->Space. With this keyboard layout, that space isn't needed.
Note that the keys denoted Caps
below are bound to AltGr
.
The reason the curly brackets are placed in the order of }{
rather than {}
is because of the curly bracket command in Vim. If you leave them as {}
, AltGr+j
will move the cursor up the page, while the default behaviour of pressing j
in Vim is to move the cursor down. If you would prefer the order to be {}
, you can simply change the bindings, see instructions below.
On Linux, I've opted for using the utility program xmodmap to change the keybindings on startup rather than setting up a new keyboard layout. This makes the keybindings much more straightforward to personalize, if you wish to do so.
- Install xmodmap from your distribution's package manager.
- Run bindkeys.sh.
Bindings changed with xmodmap in this way only stay active until system reboot, but you can simply set up bindkeys.sh to run on startup if you want to use this keyboard layout as your default one.
If you would like to modify any bindings, you can use the view-keycodes.sh script to find the correct keycodes and symbol names to use and then add the new bindings to the bindkeys script.
- Run CapsLockToAltGr.reg to remap
Caps Lock
toAltGr
in the Windows registry. - Run setup.exe and go through the installation process.
- Reboot.
- SweVi should now be an option as a keyboard layout for Swedish.
If you would like to modify any bindings, you can download Microsoft Keyboard Layout Creator and create a new keyboard layout based on this keyboard's source file.
Since we have to change the Caps Lock
binding through a registry entry on Windows, it will stay bound even if you uninstall the keyboard layout.
To restore this key to its default behaviour:
- Open the Registry Editor by running
regedit
(Win+R
). - Locate the custom "Scancode Map" entry under
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout
and delete it.