Alex Yang

now | subscribe

Need to ROT13? Use Vim!

Published 2026-07-07

Did you know Vim has a built-in shortcut to ROT13-encode the current line? Me neither! And I've been using Vim for 13 years!

You can ROT13-encode the current line by typing g?? in Normal mode. I found out about this while reading :help g (2.4 Commands starting with 'g'). 1

Apparently, this feature has been in Vim since version 5.4, which came out in 1999. 2 For reference, Vim was first released in 1991, and is currently on version 9.2, which was released this year (2026). It's pretty astounding to me how old Vim is, especially considering development is still ongoing.

Digging a bit deeper, g?? is actually a special case. The more generalized operator is g?. Just like with other operators like y (yank) or > (indent), you can combine this with arbitrary motions to apply the operation more precisely. For example, g?iw applies the operation to just the current word.

Even though it's easy enough to shell out to another program or tool to do this, it's nice to be able to do it without leaving the editor. Plus, being able to apply the operation selectively is a nice bonus, since you might be working with a document that has ROT13-encoded text interspersed with cleartext.

g? is one of several operators that start with 'g'. For instance, you may be familiar with g?'s more practical cousin, the formatting operator gq.

Tb sbegu naq ebgngr!

  1. It might seem strange that I would casually peruse a manual like this. Certainly when I first started out, I didn't touch Vim's manual. To be honest, I'm not sure I knew it existed, and plus, Googling was just easier!

    Lately, I've come to respect the power of the manual; it's reliable, quick to pull up, intuitive to navigate, and doesn't require an Internet connection. I still look things up online often, especially if I have a higher-level question or if I've forgotten Vim's quirky name for some feature (like, wildmenu... then again, I could never forget a name like that). But over the years, I've found that it's worth developing my mental map of the manual, so I know exactly where to look when I inevitably forget how some detail works, or if I just want to deepen my understanding of a particular feature. 

  2. Vim's main Git repository actually doesn't have history before version 7.0 because Vim only switched to Git in 2006. Fortunately, the maintainers have a separate ersatz Git repository with artificial commits that roughly track the source code tarball release dates all the way back to version 1 (early 90s), which made it really easy to carry out this particular investigation. I actually didn't realize this existed at first, so I went on an ultimately-fruitless-but-nonetheless-riveting adventure in which I compiled the original vi editor from source and also found Vim 5.7 on a 2001 Czech language CHIP CD on the Internet Archive, along with a bunch of other old software.