How do I normalize curly quotes to straight quotes in the current buffer?
Answer
:%s/[“”]/"/ge<CR>:%s/[‘’]/'/ge<CR>
Explanation
When text comes from docs, email, or CMS exports, it often contains typographic quotes (“”‘’) that break code snippets, Markdown tooling, or shell commands. This two-step substitution normalizes both double and single curly quotes across the whole buffer in place. It is fast, repeatable, and safer than manual replacement because the e flag avoids noisy errors if one quote type is absent.
How it works
:%s/[“”]/\"/gereplaces every left/right curly double quote with a plain"<CR>executes that first substitution:%s/[‘’]/'/ge<CR>immediately runs a second substitution for curly apostrophes/single quotesgmeans replace all matches per line, not only the firstesuppressespattern not founderrors so the command stays clean on mixed files
Example
Before:
He said “Ship it” and then wrote ‘done’.
It’s ready for “production”.
Run:
:%s/[“”]/"/ge
:%s/[‘’]/'/ge
After:
He said "Ship it" and then wrote 'done'.
It's ready for "production".
Tips
- Add
cto either substitution (/gec) when you want per-match confirmation. - If you prefer one line, you can join both substitutions with
|interactively. - Use this after paste/import steps to keep source files ASCII-clean before commits.