Being Productive

As not to give false ideas of what this post is about, let's lay it out up front. I'm going to show you how to be able to get work done in emacs. You're not going to be an emacs guru after reading this. You're not even going to be all that productive. That being said, you will be able to accomplish some work.

Configuration for an Effective Session

Following Steve Yegge's epic post, there are a few things in there that you might question. I know I did. He suggests swapping the places of capslock and control. At first this just seemed pointless. I ignored his suggestion and after 2 days, I got a case of emacs pinkie which is pain from over use. Taking his suggestion, however, has proven to be quite helpful. It keeps my fingers on the home row a majority of the time which allows for speedier typing. Another change he suggested, C-w as kill-word, seemed to be another one of those small gains that wasn't worth doing. Turns out, I still don't. Kill-word itself is quite useful, but remapping C-w makes using other's emacsen painful. I've tried to stop customizing the built-in shortcuts for portability. The only one I can't live without is C-M-hjkl for navigation between buffers.

Effective Movement

Moving around in an editor is super important. We spend a majority of our time editing moving from one place to another. Moving around vertically is done via C-v (page down) and M-v (page up) if you want to go a screen-full at a time or C-n (next line) and C-p (previous line) if you want to go a line at a time. Arrow keys also work here. To go to the beginning or end of a document, the shortcut is M-< and M-> respectively. (Yes, there is a shift in there. Emacs style is that you don't mention the shift, just the resulting character.)

Horizontal movement can be done in one of three ways. A line at a time, C-a (start of line) or C-e (end of line), a word at a time, M-f (forward) or M-b (backwards) or a character at a time, C-f (forward) or C-b (backwards) or arrow keys. It took me a while to get used to per-character movement commands, opting instead for arrow keys. Old habits die hard, but its for the best. Don't worry if you need to write these down or something. I had to keep a cheat sheet handy until I committed them to memory.

Text Surgery

Now that we have you moving around the editor, you need to know how to slice and dice things. Its important to note that emacs doesn't have a true delete command. It operates only on a copy or cut basis. This seems weird at first, but its really quite nice.

To kill (cut) an entire line from your cursor to the end of line, you press C-k. If you want the entire line gone, you combine move to start of line and kill line together and you get C-a C-k. Its important to know that kill line doesn't kill the whitespace at the end of a line. You can press C-k again on the empty line to remove it. I'm not entirely "enlightened" as to why that is yet, but Yegge's article offers fair enough reasoning for it, so I'm willing to live with that for now. One important caveat to this rule is that if you are killing multiple lines at a time C-4 C-k (kill for lines), it will eat the newline.

Take too much text? You can undo with the key combo C-/ . C-_ also works, but its crazy out of the way. Learn C-/ and thank me later. As I said earlier, emacs doesn't really have a delete command, opting for cut instead. To paste the lines you just cut, you can use C-y (which stands for yank. This might be confusing for vim users, but in emacs world, you yank things from your kill ring).

The kill ring is a very beautiful thing. Instead of a clipboard that holds your last copied bit of info, emacs offers a kill ring which is a list of things you've previously killed (cut). To access it, press C-y to yank (paste) the last item from the kill ring. If that isn't what you want, you can use M-y to cycle through the kill ring values until you get to the item you're aiming for.