How to Get Vi / Vim Keybindings in Bash, IPython, etc.
A lot of programs come with emacs keybindings by default. If you're a vim user,
you can make your life easier and more productive by switching to vi mode
instead. This lets you edit your command line using familiar vi shortcuts
(ESC
to enter command mode, B
to go one word back, dt/
to delete until
the next slash, and so on).
To get vi keybindings in bash, add the following to your ~/.bashrc
:
set -o vi
bind -m vi-insert "\C-l":clear-screen
To get vi keybindings in IPython, the MySQL client, and many other tools that
use the GNU Readline library, add the following to your ~/.inputrc
:
set editing-mode vi
C-L: clear-screen
C-l: clear-screen
(The C-l
thing is a useful shortcut for clearing the screen. It's there by
default in emacs mode, but in vi mode it has to be specified by hand.)