Ravines are better than plateaus

How to use vim and vi key bindings and shortcuts inside bash and zsh

In Uncategorized on March 3, 2012 at 22:19

During my last talk at the ruby underground last week, one of the biggest “aha” moments for the crowd was one I did not anticipate.

I switched to command line mode to explain something and mentioned how cool it was that I am using vim key bindings to edit the command line text. I simply press Esc to start moving around using b or w , then I can use “cow” to edit a current word on the command line etc..

Someone mentioned that was the one thing that made the talk worthy coming to for him.

To make this happen, I was using a .zshrc file from astrails.

but the magic is very simple to accomplish. by default you probably have emacs style key bindings in your command line. but if your’e a vim fan (as were the astrails guys I interned with for 6 months) you can change your .zshrc file to add this little line:

bindkey -v

if you’re in bash instead of zsh you can use

set -o vi

that’s it. next time you load a command shell you can Esc away and use vim key bindings.

About these ads

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: