I do most of my editing inside of vim inside of xterm. Yes, plain old xterm. And I like to use splits in vim, which means a lot of control-w’s to manage and navigate around them. Then I noticed there’s this windows key on my keyboard that doesn’t really do anything useful. So I thought, why not make windows-j and k move up and down among vim split windows?
It turns out to be fairly easy to do with xterm. The following in
~/.xresources
makes the windows key into a control-w prefix for most keys:
XTerm*VT100.Translations: #override \
~Shift Super <Key>A: string(0x17) string("a") \n\
~Shift Super <Key>B: string(0x17) string("b") \n\
~Shift Super <Key>C: string(0x17) string("c") \n\
~Shift Super <Key>D: string(0x17) string("d") \n\
~Shift Super <Key>E: string(0x17) string("e") \n\
~Shift Super <Key>F: string(0x17) string("f") \n\
~Shift Super <Key>G: string(0x17) string("g") \n\
~Shift Super <Key>H: string(0x17) string("h") \n\
~Shift Super <Key>I: string(0x17) string("i") \n\
~Shift Super <Key>J: string(0x17) string("j") \n\
~Shift Super <Key>K: string(0x17) string("k") \n\
~Shift Super <Key>L: string(0x17) string("l") \n\
~Shift Super <Key>M: string(0x17) string("m") \n\
~Shift Super <Key>N: string(0x17) string("n") \n\
~Shift Super <Key>O: string(0x17) string("o") \n\
~Shift Super <Key>P: string(0x17) string("p") \n\
~Shift Super <Key>Q: string(0x17) string("q") \n\
~Shift Super <Key>R: string(0x17) string("r") \n\
~Shift Super <Key>S: string(0x17) string("s") \n\
~Shift Super <Key>T: string(0x17) string("t") \n\
~Shift Super <Key>U: string(0x17) string("u") \n\
~Shift Super <Key>V: string(0x17) string("v") \n\
~Shift Super <Key>W: string(0x17) string("w") \n\
~Shift Super <Key>X: string(0x17) string("x") \n\
~Shift Super <Key>Y: string(0x17) string("y") \n\
~Shift Super <Key>Z: string(0x17) string("z") \n\
Shift Super <Key>A: string(0x17) string("A") \n\
Shift Super <Key>B: string(0x17) string("B") \n\
Shift Super <Key>C: string(0x17) string("C") \n\
Shift Super <Key>D: string(0x17) string("D") \n\
Shift Super <Key>E: string(0x17) string("E") \n\
Shift Super <Key>F: string(0x17) string("F") \n\
Shift Super <Key>G: string(0x17) string("G") \n\
Shift Super <Key>H: string(0x17) string("H") \n\
Shift Super <Key>I: string(0x17) string("I") \n\
Shift Super <Key>J: string(0x17) string("J") \n\
Shift Super <Key>K: string(0x17) string("K") \n\
Shift Super <Key>L: string(0x17) string("L") \n\
Shift Super <Key>M: string(0x17) string("M") \n\
Shift Super <Key>N: string(0x17) string("N") \n\
Shift Super <Key>O: string(0x17) string("O") \n\
Shift Super <Key>P: string(0x17) string("P") \n\
Shift Super <Key>Q: string(0x17) string("Q") \n\
Shift Super <Key>R: string(0x17) string("R") \n\
Shift Super <Key>S: string(0x17) string("S") \n\
Shift Super <Key>T: string(0x17) string("T") \n\
Shift Super <Key>U: string(0x17) string("U") \n\
Shift Super <Key>V: string(0x17) string("V") \n\
Shift Super <Key>W: string(0x17) string("W") \n\
Shift Super <Key>X: string(0x17) string("X") \n\
Shift Super <Key>Y: string(0x17) string("Y") \n\
Shift Super <Key>Z: string(0x17) string("Z") \n\
~Shift Super <Key>bracketright: string(0x17) string("]") \n\
Shift Super <Key>bracketright: string(0x17) string("}") \n\
~Shift Super <Key>minus: string(0x17) string("-") \n\
Shift Super <Key>minus: string(0x17) string("_") \n\
~Shift Super <Key>equal: string(0x17) string("=") \n\
Shift Super <Key>equal: string(0x17) string("+") \n\
Shift Super <Key>comma: string(0x17) string("<") \n\
Shift Super <Key>period: string(0x17) string(">") \n\
Shift Super <Key>backslash: string(0x17) string("|")
It took longer than I expected, but I’ve mostly managed to retrain my fingers to use windows-j, k, =, o, etc. I also found that windows-q is easier to type than :q, so I do that most of the time now too.
While on the subject of the xterm translations table, here another nifty trick:
Ctrl <Key>plus: larger-vt-font() \n\
Ctrl <Key>minus: smaller-vt-font() \n\
Control-plus and minus to increase and decrease the font size on the fly. You
may want to set explicit values for XTerm*VT100*font1
through font6
to
customize the fonts used.
(If you’re using a desktop environment or something that doesn’t load
~/.xresources
automatically, you’ll have to figure out how to run xrdb ~/.xresources
at the appropriate time.)