If you use Emacs, you can stop reading now. If you don’t, there’s a possibility that you may not be aware of an incredibly powerful productivity-boosting tool that works in almost every OS X app. Read on.

Take Control · The trick I’m about to describe works whenever you’re editing text: Gmail, Pages, Keynote, wherever. It relies on the “Control” key, which is down on the lower left corner of most OS X keyboards (but stay tuned for a trick to make it more accessible). The trick is, hold down the “Control” key while you’re hitting another, for example “A”; let’s call this “C-A”.

C-A

Go to the beginning of the line.

C-E

Go to the end of the line.

C-F

Go one character forward.

C-B

Go one character backward.

C-P

Go to the previous line.

C-D

Delete the character at the cursor.

C-N

Go to the next line.

C-K

Erase all the characters to the end of the line.

C-T

Flip the character your cursor is on and the one before it.

Notes · Not all these are available in all programs. I’ve listed them in decreasing order of availability; C-K and C-T sometimes don’t work. Also, you get surprises; for example, in Firefox, if you hit Command-F to search, that opens a little search window at the bottom and it steals C-A and C-F and a few others. Bad, bad Firefox!

Control-K is particularly useful when you’re in a Google search window and it insists in filling in more words than you want to search for. I.e., you type in “owl dropping” and it insists you want “owl droppings photos”. Get as far as you want, C-K, Enter, and there you go.

The Bottom Line · When you’re working hard with your keyboard, you can work harder and go faster if you don’t have to take your fingers off the keyboard, which you do most often to reach the arrow keys; only with these keystrokes, you usually don’t need to. So you can go faster.

Fatter Control Key · If you like these, you may become irritated that the control key is stuck way down in the corner of the keyboard where you have to fish around for it. So, here’s what you do: Open the Mac system preferences, then the Keyboard preferences, and down in the lower right corner of that screen there’s a “Modifier Keys” button. Open that up, and tell it to use the Caps Lock key as the Control key. Who needs Caps Lock anyhow? And having a big fat Control key right there beside the “A” is pretty wonderful.

Emacs · These keystrokes were first seen in Emacs, which you don’t need to know about for this to be useful, but just for background, here’s what noted geek/author Neal Stephenson had to say about it:

In the GNU/Linux world there are two major text editing programs: the minimalist vi (known in some implementations as elvis) and the maximalist emacs. I use emacs, which might be thought of as a thermonuclear word processor. It was created by RichardStallman; enough said. It is written in Lisp, which is the only computer language that is beautiful. It is colossal, and yet it only edits straight ASCII text files, which is to say, no fonts, no boldface, no underlining. In other words, the engineer-hours that, in the case of Microsoft Word, were devoted to features like mail merge, and the ability to embed feature-length motion pictures in corporate memoranda, were, in the case of emacs, focused with maniacal intensity on the deceptively simple-seeming problem of editing text. If you are a professional writer – i.e., if someone else is getting paid to worry about how your words are formatted and printed – emacs outshines all other editing software in approximately the same way that the noonday sun does the stars. It is not just bigger and brighter; it simply makes everything else vanish. – from In the Beginning was the Command Line (1998)

This blog entry, and all the others here, are written in Emacs.



Contributions

Comment feed for ongoing:Comments feed

From: Sam Aaron (Jun 29 2013, at 13:19)

C-y also works, pasting (or is that yanking?) back what was cut with C-k. Interestingly this is orthogonal to the system-wide paste buffer.

[link]

From: Eric H (Jun 29 2013, at 13:21)

I recently started using OS X's "Mail", and I'm constantly irked by not being able to use the option key as I expect -- for example, everywhere else besides Mail, option-b moves the cursor backwards one word (i.e., it's the equivalent of Emacs' Meta-b). But in Mail, it just inserts some weird character that I don't want. Grr.

[link]

From: Bob Monsour (Jun 29 2013, at 14:00)

As a former Emacs user, I have loved the OS X embrace of those keystrokes. What I was lacking was the "fatter" control key from my old PC days. Thanks for that non-obvious tip.

Separately, I pick up your feed in the Feedly reader. Yours is the only feed where the url associated with the title of the post is not a link to your blog post. Instead, it's simply an about:blank link. Not sure if it's your feed (which I'd find really hard to believe) or a mis-read on Feedly's part. Thought you might want to know given the swarms that have migrated there as a result of the demise of G's reader.

[link]

From: Michael Weisman (Jun 29 2013, at 15:18)

Also worth noting that all of these work in iOS as well with a bluetooth keyboard.

[link]

From: David Waite (Jun 29 2013, at 16:24)

There are other extensions Apple has, which unfortunately start to falter as you use Java and Firefox/Chrome and all the other environments that emulate OS X rather than using the built-in libraries.

As an example, one which Chrome has just finally started supporting is that you can hold down shift during all of the previous cursor commands to select from the current to new cursor position. (ctrl-shift-a selects to the beginning of the line, etc).

Unfortunately getting used to these has the side effect that you start to avoid third party software like Microsoft Office for Mac. They unfortunately have a tendency to try to behave more like Office for Windows than as any other Mac app, and keyboard shortcuts in particular can cause you to trigger the wrong behavior almost if by instinct.

[link]

From: John Roth (Jun 29 2013, at 18:00)

Thanks for the list! Control-d (forward delete) and control-o (new line but leave the cursor on the old line) also both work.

[link]

From: ssp (Jun 30 2013, at 04:45)

If you love these key bindings you may enjoy the fact that you can set them up with calls to methods in the Cocoa text system using the file ~/Library/KeyBindings/DefaultKeyBinding.dict

https://developer.apple.com/library/mac/#documentation/cocoa/Conceptual/EventOverview/TextDefaultsBindings/TextDefaultsBindings.html

So if Apple’s defaults aren’t enough for you, it may still be able to retrofit the missing parts in case the Cocoa text system has methods for them.

[link]

From: Duncan Ellis (Jun 30 2013, at 05:48)

Also, C-U which deletes to the beginning of the line. Can't remember if that's an emacs key combination or an ASCII one - I've been using it since the early 80s since it worked on Acorn machines.

[link]

From: Jared (Jun 30 2013, at 13:17)

Note that you have to re-map Caps Lock to Control for each keyboard. If you have a laptop and an external keyboard, you'll have to do it for both.

[link]

From: John Cowan (Jul 01 2013, at 17:33)

Feedly has now fixed the about:blank problem.

[link]

From: Tom De Leu (Jul 04 2013, at 00:10)

As far as I'm aware, these shortcuts are thanks to the GNU Readline library. A longer list here: http://www.bigsmoke.us/readline/shortcuts

[link]

From: John Hart (Jul 17 2013, at 12:36)

Thanks Tim! I'd, of course, prefer vim bindings, but that's OK.

Ctl-A is especially useful when editing text in webforms, because Command-Left Arrow (another global shortcut for "start of line") will instead navigate you off the current page unless the page explicitly handles that case.

I've been burned by this before. It's very frustrating.

Nowadays I end up using "It's All Text!", a cutely-named firefox extension (https://addons.mozilla.org/en-US/firefox/addon/its-all-text/) that lets you use $EDITOR for text areas...

Sadly, I know of no such extension for Chrome.

[link]

author · Dad
colophon · rights
picture of the day
June 29, 2013
· Technology (90 fragments)
· · Mac OS X (119 more)

By .

The opinions expressed here
are my own, and no other party
necessarily agrees with them.

A full disclosure of my
professional interests is
on the author page.

I’m on Mastodon!