vimtricks.wiki Concise Vim tricks, one at a time.

How do I ROT13 only the word under the cursor for quick anonymization?

Answer

g?iw

Explanation

g? is Vim’s built-in ROT13 operator. Combined with a text object like iw, it becomes a precise way to obfuscate one token without touching surrounding punctuation or layout. This is useful when sharing logs, snippets, or repro cases where you want to hide identifiers while preserving structure and line length.

How it works

g?iw
  • g? starts the ROT13 operator
  • iw targets the inner word under the cursor

Because this is an operator-motion combo, you can swap iw for other motions and text objects (g?ap, g?}) to scale from one word to larger regions. The transformation is reversible: running the same command again restores the original text.

Example

Starting text with cursor on token:

token user_email

After g?iw:

gbxra user_email

This keeps delimiters and neighboring text intact while obscuring the target word.

Tips

  • Use g?ap to obfuscate an entire paragraph quickly before pasting into tickets.
  • Pair with macros when you need repeatable anonymization across similarly structured lines.

Next

How do I jump to the next lowercase mark in Vim's mark order?