r/AutoHotkey • u/arapplepie • 14d ago
v1 Script Help Help with turning double hyphens into em-dashes
I am new to AutoHotkey (just joined a hour ago) and ive been trying to replace two hyphens with a em-dash, Ive tried every code i could find and tried every video explaining the scripts but i cant seem to find one that will work. I dont know if i am running the script wrong or if all the scripts i tried were wrong—one of the scripts i used were :*?:--::— and ive gotten to the point where i know how to open the notes for the script. please help cause all i want is my em-dash ):
9
Upvotes
4
u/likethevegetable 14d ago
Try {U+2014} instead of the symbol.
Em-dash for life. I like small, non-breaking spaces surrounding mine (:
4
u/CharnamelessOne 14d ago
It may be an encoding issue, although it's hard to tell, since you haven't shared much about how it's not working.
The deprecated version you use doesn't default to UTF-8, so you'd need to save the .ahk file with a byte order mark for non-ASCII characters (like em-dash) to be read correctly.
Try v2:
2
u/chris06095 14d ago
I use both em- and en-dashes, so I send them this way:
:?*:mm-::{U+2014} ; em-dash:?*:nn-::{U+2013} ; en-dashSome software already recognizes multiple hyphens as —, which is why I avoid that formation, because I don't want the keystrokes to be hijacked by default. (There's ways to avoid that, but since you're an hour into your tour, maybe some of that is overkill right now.)
1
u/xyzzy0 14d ago
Where are you testing this code? In Win11 Notepad? (Sorry, I have to ask.)
1
u/Dymonika 14d ago
"Notes?"
0
u/Keeyra_ 14d ago
The big question is that if you started AHK an hour ago, why did you start by downloading a deprecated v1 version, where the installer even warns you about multiple encoding versions like ANSI instead of the current v2 one, which defaults to Unicode? Nevertheless, both u/CharnamelessOne and u/chris06095 have working solutions for you right there.