Why you should try Emacs if you are a Bash user

Sakis Kasampallis | Mar 23, 2013 min read
Are you a GNU Bash user but you are not using Emacs? Perhaps you should consider trying it. You will be amazed by the similarities...

I know, your IDE (Eclipse, QT, etc.) is superior and you are extremely productive with it. Why bother using an ancient editor like Emacs? I will not begin another flamewar by comparing popular IDEs with Emacs. Choose whatever you prefer during programming. But if you want to be productive while using a UNIX-like system, Emacs (and of course Vim but I can't speak for Vim since I'm an Emacs user) can really help you.

The truth is that if you are already productive in Bash (mandatory reading: Bash Shortcuts For Maximum Productivity) you are familiar with Emacs but you don't know it yet :) The default key bindings of Bash are also used by Emacs. Let me show you some examples (my apologies to screencast haters but that's the best way of demonstrating keyboard typing):


So, what does this screencast demonstrate? My goal is to use the find command for searching all files with the suffix .conf that live under the /etc directory. First fix: I mistyped .cofn instead of .conf and used the transpose character function (C-t)* to correct the mistake. Second fix: I forgot that find expects the searching path as its first argument and incorrectly provided it as the second. To fix that I first used C-p to access the most recent command in the command history (this functionality is not offered by Emacs as such). I then used the kill function (C-w) to "cut" backwards one word, C-a to go to the beginning of the line, M-f to go one word forward, and the yank function (C-y) to "paste" the most recently killed word (that is, the search path) at the expected place.

The moral of the story: When you learn about a new shortcut in Emacs, try it also in Bash. There's a great chance that its behavior will be very similar (if not exactly the same).

* In case you are not familiar with the Emacs terminology: C typically means the Ctrl keyboard button, and M means the Alt keyboard button. As an example M-f means pressing first Alt followed by f (move the prompt one word forward).