Xmodmap for quick PHP programming in Linux

When I program Clojure and PicoLisp I use Emacs and it’s the way things are done in Emacs which inspired me to looking into making myself more productive doing PHP in Eclipse.

Since Ctrl and Alt are used heavily in Emacs, separately or in conjunction the first thing an Emacs user usually does is to remap the Caps Lock button to being a Ctrl button in order to get better access to it.

This works fine in Eclipse too, saving and deleting lines go quicker for instance.

It can be used in a much better way though, using xmodmap to make it into a second kind of Shift button. This will allow you to map stuff like $ on your home row when you press the Caps Lock button.

You first start with exporting your current layout with xmodmap: xmodmap -pke > .Xmodmap

If you then open .Xmodmap in a text editor your will se lines looking like this: keycode 25 = w W w W w W lstroke Lstroke

What we want to do first is to convert the Caps Lock key to being a new type of Shift so I change the keycode 66… line to: keycode 66 = Mode_switch

Note that you can comment lies with !.

As you can see my Caps has keycode 66, you can easily check what kind of codes various buttons have running a program called xev.

Here’s an example of a line I’ve changed: keycode 32 = o O equal O o O oe OE

See that equal in the third place? If I press Caps Lock and then o I get =, much better than the normal spot close to the backspace button.

Now you know how to basically change the rest, below you can see some other changes I’ve made:

keycode 39 = s S underscore S s S ssharp section
keycode 40 = d D minus D d D eth ETH
keycode 41 = f F parenleft F f F dstroke ordfeminine
keycode 42 = g G parenright G g G eng ENG
keycode 43 = h H bracketleft H h H hstroke Hstroke
keycode 31 = i I dollar I i I rightarrow idotless
keycode 44 = j J bracketright J j J j J
keycode 45 = k K braceleft K k K kra ampersand
keycode 46 = l L braceright L l L lstroke Lstroke
keycode 57 = n N Left N n N n N
keycode 58 = m M Right M m M mu masculine

When you’re done you load the changed map by running: xmodmap .Xmodmap and that’s it!

I didn’t set the above command as a startup command but got a window after login promting me if I wanted to load it, quite handy since if I’m doing Emacs I don’t want it loaded.

If you save the original as .Xmodmap and the changed one as .Xmodmap_eclipse for instance you can easily create buttons on your menu to switch between them.

Related Posts

Tags: , ,