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:", "”");