vim-bindings in all applications
25 April 2011
Here I’ll describe how I use vi or vim keymaps in every application that I use.
Xorg
I’d recommend mapping the useless Caps Lock key to ESC using xmodmap. This will affect all applications in X, including Vim. This is how it might be done using xmodmap:
xmodmap -e 'clear Lock' -e 'keycode 0x42' = Escape
Virtual Console (TTY)
Having Caps Lock mapped to ESC outside of X is a tiny bit trickier. Make sure you’re in a TTY when you do this, or else you’ll get false results!
# Let's find out what keycodes map to the keys we want to remap
dumpkeys -l | grep -P 'escape|caps'
Caps Lock 58
Escape 1
Put our new definition in a file called /usr/local/share/kbd/keymaps/caps_to_esc and use the loadkeys application to load our new values:
echo 'keycode 58 = 1' >> /usr/local/share/kbd/caps_to_esc
loadkeys -q /usr/local/share/kbd/caps_to_esc
Shell
Bash and readline
Bash uses readline which supports a vi keymap. In bash you can enable it by issuing:
set -o vi
You can activate it for other applications using readline by placing this in your $HOME/.inputrc:
set editing-mode vi
set keymap vi-insert
See readline(3) for a full list of options. Here’s my setup.
Zsh
Zsh does not use readline, but it’s own command line editor called zle. You can still place this in your shell resource files though:
set -o vi
Additionally, you can use the zle function bindkey to manipulate your keymaps. See
zle -l
for a full list of keymaps.
Git
tig is a nice ncurses git repository browser with vim movement keys being the defaults.
Irssi
Irssi was for a long time the only application where I had to use the cursor keys and other evilness. Along came Shabble and saved the day with his wonderful vim-mode plugin. Make sure to check out his other scripts as well, there are some really nifty stuff in there.
PDF (apvlv)
For PDF viewing I use apvlv which is the least annoying PDF viewer I know of and it ‘works just like Vim’.
Firefox
I’ve for a long time used the Firefox addon Vimperator, and now I’m using the fork called Pentadactyl. If you’re a Vim user, you really can not browse the web without this.
Music (MPD)
Pimpd2
I’ve written a command-line based MPD client called pimpd2. It also features a built-in interactive shell, using readline, so the vim keymap works there.
ncmpcpp
ncmpcpp is a client built using C++ and ncurses. It features vim-like bindings fresh out of the box.
Video (mplayer)
The obvious choice for video is mplayer which is highly configurable. My input configuration for it can be found here.