vi style shortcuts for linux shell

Being a vi fan, I found it really difficult to remember different shortcuts for editor and a shell. These are the utilities which I use a lot specially on my Debian system. Even on Windows when I use cygwin, I tend to use Vi and the shell of cygwin. Recently I was trying to setup shortcuts on my Debian so as to switch workspaces, move windows etc, and I realized that some of the key combination that I was setting up conflicted with ‘default’ shell short. On exploring more, I found that one can configure his shell to accept Vi style shortcuts. This really solved three things for me.

1. I don’t need to remember default shell shortcuts.The default shortcuts are useful for people using ’emacs’ editor.

2. The choice of shortcuts that I could choose for moving window around, switching desktops etc. even if they conflicted with the shell shortcuts, I need not worry as I wouldn’t need to use them in shell as now I had Vi style shortcuts.

3. If I am using a utility like ‘screen’ for remote logins, the screen commands, which being quite like ‘default’ shell shortcuts, did not create any trouble for me.

To set Vi style shortcut, it is as simple as following the steps below:

1. Open your .bashrc

2. Add the following line somewhere in your .bashrc

set -o vi

3. Run your .bashrc file

Now you can use vi style shortcuts to move around. For example, you could use:

In ‘escape’ mode:

‘dd’ to remove the entire line

‘dw’ to remove the following word

‘b’ to move one word backward

‘f’ to move one word forward


Although I have been using Vim and Shell for quite many years, but unfortunately I got know about Vi style shell shortcuts only recently. It comes as a boon and savior for me. Hope you would also find it useful, if you did not already know about it.


One thought on “vi style shortcuts for linux shell

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s