2025-01-27 org-use-sub-superscripts

Today I have a short tip which is very niche, but potentially useful to some people. At least, it’s very useful for me. ;-)

I have a big Org file with work-related notes. This means that it contains lots of code snippets (mostly SQL, sometimes Bash or JavaScript). It also means that non-code notes often contain references to identifiers.

Being a Lisper, I obviously like my identifiers to be kebab-case. Of course, you can’t use those in SQL or JS, so in those languages I’m stuck with snake. (I hate camelCase and its ilk with passion, although Emacs can make them just a bit more palatable.)

This poses a minor but annoying problem. Surrounding each and every identifier with ~ to mark it as “code” is very inconvenient, especially when I want to copy them to the kill ring. On the other hand, if I don’t do that, I get a result looking like this:

snake case identifier.png

The reason is obvious – Org mode tries to be helpful and treats _ as introducing a subscript.

I thought that I almost never use actual subscripts in my Org documents, so why not turn this feature off? Initially I thought of a very quick and dirty hack, namely redefining the face Org mode ues to show sub- and superscripts. I learned that it is just the general face used for LaTeX fragments, so changing it might be too drastic a step. I looked at the manual, though, and was pleasantly surprised. It turns out that there is an easy way to disable treating characters or words after _ as subscripts. You just need to set the org-use-sub-superscripts option. Go read the relevant section to learn what are the possible values and how to set it up globally or only for a single Org file.

CategoryEnglish, CategoryBlog, CategoryEmacs, CategoryOrgMode