Skip to the content.

Keybindings in the termial

Default: Emacs-style keybindings

By default, the terminal running bash support the Emacs keybindings, e.g.,

A nice cheat sheet for the default keybindings can be helpful.

vi-style keybindings

However, this default behavior can be changed to vi keybindings, including a command and an insert mode. To get this to work, you need a file named .inputrc in your home directory with the following contents.

set editing-mode vi
set keymap vi-command

The prompt starts in insert mode, so you can type as usual. To switch to command mode, hit ESC. Now many of the vi commands work, e.g.,

The main time savers are of course vi’s movement operators in command mode, e.g., 3f/ would move the cursor to the third slash, starting to count from its current location.

A convenient cheat sheet in PDF format is available.

It takes some time getting used to, but will save you quite some keystrokes at the end of the day.