I want my per-line code comments to line up nicely, so I’ll often add a bunch of spaces by hand to make things just so. I realized that, being Emacs, there must be an easier way to handle this. Of course there is.
;; Align comments in marked region
;; Via https://stackoverflow.com/a/20278032
(defunjab/align-comments (beginning end)"Align comments within marked region."(interactive "*r")(let(indent-tabs-mode align-to-tab-stop)(align-regexp beginning end (concat "\\(\\s-*\\)"(regexp-quote comment-start)))))
Here’s an example of what I was working on, with horribly un-aligned comments.
Much better. It’s cool because it uses comment-start so it works with any language’s comment syntax. There are probably 17 other ways of doing this that I haven’t discovered, but this works.