Rory's Blog
Home
Blog
Projects
Facebook
Google+
Github
RSS

Vim: In the Shell

03/22/15

So, I said my next vim post would be about functions, but I rediscovered something since then:

set -o vi

This gives me vi-esque control on the bash shell commmandline. Meaning, I can exit insert mode and edit as I would in Vi.

Note that I'm saying Vi, not Vim. This isn't "Vi iMproved", it's just vi and it's missing some of the stuff I use regularly. But, this is okay, it has lots of stuff that will make me faster than the emacs key-bindings that are default on the shell

Now, I knew about this before, which is why I said I "rediscovered" it. Once upon a time I wanted to learn emacs key-bindings, too, for various reasons (the vim commandline being related), but I've decided that, for now, that is not a priority so I'm going to get used to using vi key-bindings in the shell.

There is a slight annoyance, however, already in using this shell, and that is when I press ctrl-l in insert mode, I get an annoying ^L. Not acceptable. Ctrl-l works as anticipated when in cursor mode, but I want it to always work as anticipated.

Luckily, this is an easy fix:

bind -m vi-insert 'Control-l: clear-screen'

This makes ctrl-l do exactly what I want it to do. Hooray!

It's nice to have vim with me in the terminal wherever I go. Maybe I'm becoming too dependent on it.... I'll carefully consider that and think of strats when I believe it's true.