💾 Archived View for idiomdrottning.org › zw-slash captured on 2021-12-03 at 14:04:38. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
I found that sometimes when I post long words I kind of want them to be able to break at slashes or hyphens in narrow windows. To do that, I can insert a unicode zero-width space after the slash.
For emacs, here’s a li’l Emacs thing you can set to whatever. Without a prefix, it inserts a slash and a zero-width space. With a prefix, it asks you for another character instead of the slash.
(defun zw-slash (pref) (interactive "P") (if pref (quoted-insert 1) (insert "/")) (insert-char ?\u200B))
There’s also something called a soft hyphen in case you have long words without any punctuation, like AsÂmoÂraÂnoÂmarÂdiÂcaÂdaistiÂnaÂculdaÂcar.
(defun soft-hyphenate-region (beginning end) "Turn hyphens into soft hyphens in region" (interactive "*r") (save-excursion (goto-char beginning) (while (search-forward "-" end t) (replace-match "Â"))))
This one I’m not gonna bind because I don’t think I’ll use it often but it’s nice to have available in the M-x repertoire.