7. January 2014

Programmer-friendly German keyboard layout on GNU/Linux

German keyboards are usually pretty annoying for programming. Mapping the third-level of the buttons D, F, C, V to {, }, [, ] places the curly braces and brackets at more convenient locations without destroying much of the benefits of a German keyboard.

Why are the curly braces, the square brackets all on the third level, requiring to type both the third-level chooser (usually either Alt Gr or Ctrl Alt) and the appropriate key (7, 8, 9, or 0)? To make things worse, all these frequently used characters are located on the right of the keyboard. This makes it for example rather cumbersome to hit both Alt Gr and 7. In order to save time with typing, one is free to modify the keyboard layout. Mapping the third-level of the buttons D, F, C, and V to {, }, [, ] places the curly braces and brackets at more convenient locations without destroying much of the benefits of a German keyboard. What worked for me was to edit /usr/share/X11/xkb/symbols/de and change the basic German layout by appending:

key <AC03>  { [ d, D, U007B, U00D0 ] };
key <AC04>  { [ f, F, U007D, U00AA ] };
key <AB03>  { [ c, C, U005B, U00A9 ] };
key <AB04>  { [ v, V, U005D, U201E ] };

Edit: For those, who want to go all in, there is the Neo keyboard layout for German speakers, which makes stunts like the one described above unnecessary (thanks T.K. for reminding me of this). Hence, one might consider switching completely to Neo instead of applying workarounds to the worst of all annoyances.