Posted on Monday, March 16, 2015
I use Linux on both my desktop workstation and my laptop. I mention this because, while it marks me out as kind of an oddball in most respects, it establishes my credentials pretty effectively on one point: I know how to edit text.
Unlike every other operating system in common use today, Linux (and Unix-like systems more broadly) is unashamed about its love affair with plain old text. Things that other OSes hide behind shiny, clicky “control panels” are squirreled away by *nixes into text configuration files. Much of how you automate procedures in such systems involves piping text output from one program into another. Where other systems race toward any opportunity to keep the user from having to put their hands on a keyboard, *nixes stubbornly look for ways to keep the user from having to take their hands off the keyboard.
All of which is probably why *nixes are unappealing to most users unless they are hidden behind a thick layer of graphical candy, as OS X does. But it makes those of us who do use them really, really good at editing text. So I’m writing this to share one trick I’ve learned by using such systems.
Longtime Readers™ will already know that I’m fond of putting that little trademark symbol at the end of the phrase “Longtime Readers.” But let’s look at a mechanical question for a second: how do you actually put a symbol like that in there?
For most people, the answer will involve opening up an application (Character Map in Windows, Character Viewer in OS X), finding the symbol you want in there, clicking some buttons to copy it to the clipboard, and then pasting it into your text where you want it. That works, but — let’s be real here — it’s incredibly clunky. You’re talking about multiple clicks just to get a single special character in place. That’s a pain.
Some more advanced users will have learned an alternate input method, Alt codes, that can be entered straight from the keyboard; no special app or multiple clicks required. But while they’re easier than using a character map, they force you to remember a special numeric code sequence for each character you want to use. And those code sequences have nothing to do with the particular character they represent — what correspondence does the number “164” have with the character “ñ”? — so learning new characters means memorizing new numbers for each one. And capitalized characters are coded separately from lowercase ones, so just because you know the code for ñ doesn’t mean you’ll be able to use that knowledge to use the character Ñ. So it’s better, but not by much.
All of which means that, when confronted with special characters, rather than deal with these frustrating input methods people tend to take lazy shortcuts like dropping accents off non-English characters. So suddenly Luis Buñuel turns into “Luis Bunuel,” and “LEGO®” becomes “LEGO (R)” — all because the computer of the person typing made being accurate too hard.
People of Earth! I come to tell you that there is a better way. Better than character maps or Alt codes. So much better, in fact, that once you get used to it, you’ll find typing on a computer that isn’t set up to support it positively painful.
That better way — which I had never heard of until I started using Linux — is called the “compose key.”
Here’s how it works. You tell your computer that a specific key on your keyboard (it can be any key you like 1) is a special, magic key called a compose key. And once the compose key is pressed, rather than taking each character you type after that on its own, the computer looks to see if the characters form a compose key sequence — a series of keys that correspond to a particular special character. If they do, the computer outputs the special character; if they don’t, the keys are ignored.
All of which probably sounds similar to the above-described Alt codes. But there’s a key difference — rather than just a number, compose key sequences for characters are specifically designed to be similar to the character they should produce. This makes them easier to remember than Alt codes, and additionally makes it easy to guess the sequences for characters you haven’t used before, without having to look them up.
Let’s take as an example the ñ character mentioned above. When your system is set up with a compose key — I use the right Ctrl key for mine, since it’s out of the way of regular typing — producing this character is simple. You just type:
Compose + n + ~
… and bam, out comes “ñ”. Notice how the compose key sequence follows from the character itself; to use ñ, you type a plain “n” and then a tilde (“~”), the character closest to the accent mark the character includes.
Knowing that, can you guess how to use a compose key to produce Ñ? I bet you can:
Compose + (Shift + n) + ~
That’s right — it’s just a matter of holding down the Shift key when you hit “n”. Now you know how to capitalize any accented character.
How about turning “Longtime Readers (TM)” into “Longtime Readers™”? You guessed it:
Compose + t + m
Or how about that little registration mark (®)?
Compose + o + r
It’s Just That Easy®.
What about fractions, you ask?
Compose + 1 + 2
Compose + 1 + 4
Compose + 1 + 8
You can even use the compose key to do some of the weirder Unicode characters:
Compose + < + 3
Compose + : + )
Compose + C + C + C + P(Yes, really. Try it!)
You’re probably starting to see now how much easier this is compared to character maps and Alt codes. It makes typing special characters so easy that it just becomes part of your regular typing flow. “Special” characters become just… well, characters. Which is they way they should be.
And unlike Alt codes, which are tied to Microsoft Windows proprietary character codes, a good compose key implementation will produce clean, interoperable Unicode characters, so there’s no worry about them glitching out when copied into an email or Web page.
If you’re a *nix-using nerd like me, your system probably already supports compose key sequences, so all you have to do is check the docs to see how to start using them. But for those of you who use Windows or OS X, never fear — the power of the compose key is available to you too!
Getting a compose key on OS X: As befits its *nix heritage, a compose key is available to Mac users without having to install any additional software. However, since Apple’s entire interface philosophy is built around using the mouse rather than the keyboard, they don’t enable it by default. So to turn it on, you need to either fiddle with your settings a bit or install a new keyboard layout that has a compose key set up by default.
Getting a compose key on Windows: Windows, not being a *nix in any conceivable shape or form, has no compose key support out of the box. However, you can easily add one by installing a free, open-source utility, WinCompose. Once it’s installed, just run WinCompose and any key you specify will function as a compose key. (Or just tell Windows to run it at startup if you want compose key support all the time.)
So regardless of what platform you’re into, you can take advantage of the compose key to make your life suck less. Give it a try — and prepare to be amazed at how soon it becomes indispensable!
- Once upon a time, keyboards had an actual, physical key on them labeled “Compose” that was used for this. But since modern keyboards do not, software compose key implementations let you use whatever key you prefer in its place. ↩
This entry (and everything else on this blog) was written by Jason A. Lefkowitz. Did you like it? Subscribe to this blog's feed to get new stuff the moment it's posted. Want to read more like this? Hit the archives for more than ten years' worth of essays, or jump right to The Best of Just Well Mixed. Angry and wanting to know who to punch? Here's more information about me, including how to get in touch by email and various social networks.