How do I apply ROT13 encoding to the current line in Vim without using a motion or visual selection?
Answer
g??
Explanation
Vim has a built-in ROT13 operator g? that encodes text by rotating each letter 13 positions in the alphabet. Like other operators, doubling it — g?? — applies it to the entire current line, without needing to specify a motion or enter visual mode first.
How it works
g?{motion}— ROT13 the text covered by{motion}g??— ROT13 the current line (line-wise, likeddorgqq)- Applying ROT13 twice restores the original text (it is its own inverse)
- All non-alphabetic characters (numbers, punctuation, spaces) are left unchanged
Example
With the cursor on this line:
Hello, World!
Press g??:
Uryyb, Jbeyq!
Press g?? again to decode:
Hello, World!
Tips
g?iwROT13 encodes just the current wordg?ipencodes the entire inner paragraph- In visual mode, select text then press
g?to encode the selection - Useful for obfuscating spoilers, test data, or example output in documentation
- Combine with
:g/pattern/norm g??to encode all matching lines in one command