vi or emacs? Really?!?

Most of the operations/engineering folks I’ve come into contact with will proclaim to be “vi” people and yet, when I watch them edit a file I cringe..

They’ll use arrow keys. To change text, they’ll arrow over beyond the text they want to change and then backspace to delete it. It’s painful to watch..

We spend so much time editing files and yet it’s like a carpenter hammering a screw in because they don’t know how to use a screwdriver. (Would you hire that carpenter?)

When not editing files, we are often using various command lines; bash, mysql and many others where that knowledge could be leveraged for searching and editing command history, if they only knew how.

I get that it can be a steep learning curve to be proficient with either of these editors, but it can dramatically enhance your productivity! There’s plenty of documentation available. RTFM!

(Emacs folks can probably skip the rest of this article..)

If you do know vi and aren’t using it on the various command lines you use, you are missing out on a great feature! Use it with bash, less, mysql, bc, python, R, tclsh and many others. You can also easily build it into your own commands including shell scripts! (I’ll have more on this in an upcoming article.)

Edit or create a file in your home directory called “.inputrc“. Add the following line:

set editing-mode vi

Start up a new bash shell. Magically, your vi fingers will now know what to do! One note is that the slash “/” searches backwards in your history, not forward like in files. Also, in “command mode”, the hash “#” character will comment out the current line (useful). There are a few other differences as well, but mostly, it will now be a direct link from your brain to your fingers!

Try it and, Leverage your knowledge!

Also, try building the interactive editing capability into your own scripts. Take a look at the Interactive bash Scipts article.

One thought on “vi or emacs? Really?!?”

Comments are closed.