News

Old is GNU Again

Written by UI-Staff

Old is GNU Again

Throwback memorabilia is hot these days. From sneakers to jerseys some things are just destined to come back in style. It doesn't happen often, but sometimes technology can comeback, too. This week I talk about my recent experience of working with GNU Emacs – a feature-rich text editor created in the 1980's.

Why Should Someone Learn Emacs Today?

This was the first question I asked myself before I began forcing myself to learn a new, and notoriously difficult to learn, technology. My need for a new editor mainly arose from my daily work managing a number of remote linux servers through a command line terminal. For a long time, I got away with using NANO, a very simple text and file editor without any of the acrobatic keyboard shortcuts of Emacs or VI (another similar and popular editor).

Nano was a great editor for a long time, but I soon found myself getting frustrated when I needed to easily switch back and forth between multiple files on a server. I also missed more advanced features found in modern text editors like syntax highlighting and autocomplete. These tools help cut down on typing mistakes and errors.

My need for powerful features led me to choose between two popular text editors: VI and Emacs. I ended up chosing Emacs simply because I was able to find much more approachable learning materials for Emacs than Vi. Later in this article, I'll list some of the resources I found.

How Emacs Has Made Me More Productive

Emacs is famous for having a steep learning curve. Part of this learning curve comes from Emacs' simple design philosophy which is that your fingers should never leave the home row. This means no arrow keys and no mouse. For me, the most difficult step was learning how to navigate my text cursor without a mouse or the arrow keys. While using shortcuts has always been part of my workflow, using shortcuts like C-A (Ctrl-A) to move to the beginning of a line and C-E (Ctrl-E) to move to the end of a line took a while to sink in.

Once I started getting the hang of things, I found myself more productive in the following areas:

  • My fingers don't leave the home row when editing: less movement simply means more efficiency. More efficiency means you'll get things done quicker and have a more enjoyable time doing them.
  • Server-side editing: Using "buffers" (the Emacs version of "tabs") I can quickly switch between different files on a remote server. I can even edit them side by side in a split editor window.
  • File browsing: need to open another file from your text editor? C-x C-f will open a file prompt which you can use to quickly open other directories. Just like a normal command prompt, use the TAB key for filename autocompletion
  • Integration with modern code editors: This item was huge for me. From the onset, I did not want learning a new tool to kill my productivity for daily work. Two programs I use frequently however, TextMate and Eclipse, support Emacs-like key-bindings. These key-bindings allow you to perform a large number of operations just like you would in Emacs. This helps reinforce the myriad of keyboard shortcuts you'll be learning and makes switching from one tool to another much less painful. For instance, I often use Eclipse when compiling Java or C++. For the longest time, Eclipse's shortcuts have bothered me to no end – but emacs key-bindings have made the process much more enjoyable.

Tips for learning

  • Start with the basics – cursor navigation + cut & paste + undo. These are the operations we take for granted in daily programming tasks, so it makes sense to start here.
  • Focus on a limited set of commands and move up – Don't try to learn everything at once or decide that you'll never use your other editor again. One tactic that has worked well for me is to focus on specific features or commands each week. Don't move on until you know it.
  • Keep a cheat sheet – start with something simple and move onto a more advanced cheat sheet as you learn. Here's a good starter sheet.
  • Watch the Meet Emacs screencast at PeepCode – this screencast will introduce you to a ton of very useful features like Git integration, code-completion, and other advanced features. Geoffery's screencasts are excellent and this episode is no exception.
  • Use your editor any chance you can. The more often you use a single tool, the more likely you are to experience productivity gains as this reduces your need to switch from one application to another. If you need to write a list of things to do today, just open up Emacs and fire one off. (Note, this blog post was written with Emacs)

I couldn't begin to call myself an Emacs expert after my brief month of usage, but I can say that I've already experienced some significant gains in productivity with the relatively small subset of commands I've learned thus far. If you want to find a strong tool to add to your command-line repertoire, give Emacs a try.