'What functionality does the "g?" command provide in vim

As a beginner programmer I've been practicing vim on vimgolf recently and saw that the command "g?" was used effectively to switch many lines of 'Ivm' to become 'Vim'. I understand that this shifts each alphabetical letter 13 times to the right but do not understand how this would prove useful except in unique circumstances like these.



Solution 1:[1]

I have been using Vim since 4 years and learned about that command very early on but, even if I knew perfectly well what ROT13 was, I never found a use for g?.

Until a couple of weeks ago when I needed to add a bunch of <li> with unique IDs to a <ul> in an HTML prototype…

The starting point:

<ul>
    <li id="lorem">foo</li>
    <li id="ipsum">foo</li>
</ul>

After duplicating the two <li>:

<ul>
    <li id="lorem">foo</li>
    <li id="ipsum">foo</li>
    <li id="lorem">foo</li>
    <li id="ipsum">foo</li>
</ul>

After g?i" on the two new <li>'s ids:

<ul>
    <li id="lorem">foo</li>
    <li id="ipsum">foo</li>
    <li id="yberz">foo</li>
    <li id="vcfhz">foo</li>
</ul>

There! I found a practical use for g? in actual "programming"! Celebration!!!

Solution 2:[2]

It can prove useful on the case where you want to quickly hide some part of text that you typed in a visible vim buffer from onlookers.

For example some piece of password or token which you put in your code (but only do this temporarily, when you must).

Perhaps you want to invite a team-mate to look at some of your code, or you work in a place where people use to walk behind your back all the time so you can just rot13 the string and it is useless to them (at least in a glance). It probably works best against non technical passerby's or for short exposure period.

Keep in mind it does not rotate numbers and for security purposes it was even better if it could take a rotation size.

It can also become useful when you solve a CTF that has a rot13 challenge...

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 romainl
Solution 2