macOS includes a deeply integrated text-replacement engine called “Smart Dashes.” If you are typing a document in Pages, drafting an email in Apple Mail, or even renaming a file, and you type two hyphens back-to-back (--), the operating system will instantly and automatically combine them into a single, long “em dash” (—).
While an em dash is grammatically correct for separating clauses in a sentence, this automatic conversion is an absolute nightmare for programmers and system administrators. If you are typing a command-line flag in a terminal emulator (e.g., sudo apt-get --purge remove) or writing a comment in a script, having your double hyphens suddenly transform into an em dash will cause syntax errors and break your code.
To preserve your exact keystrokes, you must disable the Smart Dashes feature at the operating system level.
How to Disable Smart Dashes on macOS
You can turn off this auto-correction in the Keyboard settings.
- Open the System Settings (or System Preferences) via the Apple Logo in the top-left menu bar.
- Scroll down the left sidebar and click on Keyboard.
- In the right pane, look under the “Text Input” section and click the Edit… button next to “Input Sources.”
- A new window will appear containing various spelling and grammar toggles.
- Locate the toggle switch (or checkbox on older macOS versions) labeled Use smart dashes and quotes. (Sometimes they are separated; if so, uncheck Use smart dashes).
- Turn the toggle to the Off position.
- Click Done to save your changes.
The change is applied system-wide immediately. The next time you type two consecutive hyphens (--), they will remain exactly as two distinct hyphens, ensuring your code and terminal commands execute flawlessly.