Skip to content

Instantly share code, notes, and snippets.

@zakness
Last active August 29, 2015 14:09
Show Gist options
  • Save zakness/13bf99273fc2da19da4d to your computer and use it in GitHub Desktop.
Save zakness/13bf99273fc2da19da4d to your computer and use it in GitHub Desktop.
Code style guide: Curly quotes and apostrophes

Use the typographically-correct quotation characters — ‘ ’ “ ” — inside strings rather than the easy-to-type straight quotes. Not only will it look better, it wont require escaping or remembering to alternate when nesting.

OS X has default key bindings for these characters, but they don’t make sense. Save the following snippet as ~/Library/KeyBindings/DefaultKeyBinding.dict to create custom key bindings on the [ ] { } keys for these characters.

{
    "~[" = ("insertText:", "‘");
    "~]" = ("insertText:", "’");
    "~{" = ("insertText:", "“");
    "~}" = ("insertText:", "”");
}

This will make ⌥[ and ⌥] insert open and close single quotes, and ⌥{ and ⌥} insert open and close double quotes (like god intended). You must restart for this to take effect.

For more pedantic fun, check out a more comprehensive list of common bad typography habits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment