Samir Parikh · Blog · Git


Originally published on 4 December 2022

I just recently found out about GNU Readline which is a library that, as its documentation states, “provides a set of functions for use by applications that allow users to edit command lines as they are typed in.” There is a really good article by Two-Bit History that describes more of the features but what caught my attention was that you can configure how to navigate the Bash command line in your shell. I’m used to Vim-like key bindings to move my cursor around and to edit text so it’s been tedious having to learn another set of keyboard shortcuts such as Ctrl-A or Ctrl-E to move to the start or end of the line, respectively. I believe many of these are derived from Emacs.

The good news is that you can change these to behave more like vim. Just enter this command in your shell:

$ set -o vi

Now, you can use the j and l keys, for example, to move your cursor left and right. Press i to go into Insert mode to enter text. To make this behavior permanent, just create a file called .inputrc in your home directory with the following line:

set editing-mode vi

The next time you log in, your shell will automatically use the vi key bindings. For more information, please see: