+++
title = "vi-mode editing in most places"
date = "2022-11-13"
+++

# Vi/Vim bindings

For my sake, I prefer to have Vim bindings in as many places as possible.

Most shells can be configured to use Vim bindings by putting `set -o vi` somewhere in your shell startup script.

If you're using ZSH then you'll probably want an additional binding to restore CTRL-R reverse history search.

`bindkey '^R' history-incremental-search-backward`

For CLI tools that use the `readline` library then you can configure its input mode using a `.inputrc` file in your `$HOME` directory.

This affects REPLs like `ghci` and tools like `psql`.

```txt
set editing-mode vi
$if mode=vi

set keymap vi-command
# these are for vi-command mode
Control-l: clear-screen

set keymap vi-insert
# these are for vi-insert mode
Control-l: clear-screen
$endif
```
