Services vs Keybindings

I talk a lot about keyboard and text tools. Many of my projects are System Services, but I’ve also shared a pretty vast array of KeyBindings. If you’re like many of the people who contact me with questions, you’ve probably wondered what the difference is and why you would want to use both. After all, you can assign keyboard shortcuts to Services, so what’s the point of confusing keybindings?

Services

Services are scripts and Automator actions that you can run on a variety of filetypes. They’re easy to install, and you can build them quickly and easily in Automator (which comes with OS X). See the howto for full details and instructions. Most of my services run on plain text. They allow you to process selected text using your scripting language of choice (usually Ruby, in my case) and replace or append the result to the selection.

Services can have shortcuts assigned to them in System Preferences ▹ Keyboard ▹ Keyboard Shortcuts. You can build your own collection of easily-accessible, text-modifying services this way.

The major benefit to Services is that they can run scripts. This offers extensive flexibility when it comes to text processing. Any transformation you can imagine can probably be accomplished.

KeyBindings

KeyBindings are keyboard shortcuts that you can create using a system file called DefaultKeyBinding.dict. They are primarily used for cursor movement and selection modification while editing text, but they can also insert text and be used to create text macros.

KeyBindings can’t run logic or process scripts. They can, however, do things that Services can’t, such as selecting words and extending selections in either direction. They’re also blazingly fast.

KeyBindings only work on one paragraph, word or line at a time (depending on the selection). This is, in my opinion, the biggest drawback. For example, if I want to turn a single line into a Markdown bullet list item, no problem. If I want to select a series of lines and apply the same transformation to each of them, only the first one will be affected. That becomes the domain of Services.

Summary

The pros and cons of Services and KeyBindings:

KeyBinding

Service

Assignable shortcuts

✔

✔

Modify selection

✔

✘

Instant results

✔

✘

Work on multiple lines

✘

✔

Run shell scripts/logic

✘

✔

Insert text

✔

✔

Modify text

✘

✔

GUI for creation

✘

✔

Keeping them all straight

In a word, Cheaters. It’s a popup cheat sheet system. My KeyBindings are documented there, and you can quickly build a reference for Service shortcuts and new KeyBindings you add.