Emacs Commands Work in OS X, How Awesome is That?
In the beginning, there was Assembly, and from it flowed many programs. And the programmers of the day looked upon what they had wrought and judged it to be...a freaking pain in the neck. But it worked, and you don't just throw away something that works. However, it only took that first programmer about 15 minutes working with Assembly to realize that something better was needed. He might not have known what, exactly, was needed, but he knew it was something. And so began the drive to develop a better language. Eventually that language was created. Shortly thereafter, a better text editor was demanded. Which just proves that old adage about how if you give a programmer a cookie he is going to ask for glass of milk and a text editor that can handle regular expressions. But I digress.
There are two very old, very powerful text editors out there, one of which is emacs and the other which is not emacs. Some of you out there have chosen the path of the enlightened and learned emacs. Some of you have not. Yes, though it may be inconceivable, vi is still in use. Not by me, but, if rumors are to be believed, by someone.
But wait. I know there will be those who insist that much can be gained by choosing the other path and learning vi. To those people I would calmly point out that I'm already married and thus have no need for any more pain in my life. (Honey, you know that was a joke. I love you, really.) But enough talk of vi, today the subject is emacs. Or more accurately, how learning emacs can make using OS X a much faster experience.
There are certain emacs commands that can be used in just about any generic text field in OS X. First I will list some commands and then I will explain where they can be used.
One last thing: every one of these commands starts with the "Control" key, unlike standard OS X commands which start with the "Command" or "Apple" key. So for simplicity I will shorten "Control" to just C. So, the command C-a should be read as "hold the control key and press the button [a]". Now onto the list of commands.
[C-a] go to start of line
[C-e] go to end of line
[C-f] move to the next character
[C-b] move back one character
[C-p] move to the previous line
[C-n] move to the next line
[C-m] insert new line (return)
[C-t] transpose two characters
[C-k] cut from cursor to end of line
[C-d] delete forward
[C-h] delete backward
These are all really handy commands to have at your disposal. For instance, you open Firefox and type in a URL, but halfway through it you decide you don't actually want to go to that website. You have lots of ways to clear the text you just typed, but one of the quickest ways is to use the aforementioned commands. In this case you would type [C-a] to get to the start of the line and then [C-k] to delete everything you just typed. Congratulations, you just hit 3 keys and saved yourself two whole seconds of using the mouse. And who doesn't like saving time?
Anyway, these commands can be used in any standard text field in OS X. This includes the search bar of almost any application (like Safari or Firefox), widgets like Stickies, the Spotlight search bar, or just about anywhere in Text Edit.
I realize that this whole exercise seems like a lot of work for not much gain, and for those of you who don't use emacs regularly I must totally agree. But for those few users out there who use both emacs and OS X, you will all get giant nerd-gasms from the coolness of this trick.
Or maybe that was just me.