Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've been using Vimgolf as a bit of professional development.

In this particular task One of the best solutions is the following command.


I understand ZZ is to save and exit - and that control-v is entering visual mode, but the Gg? looks like sorcery for me.

Google is letting me down a little bit with the search - not least becaues it appears ? is overloaded in both Google and vim... Can someone pick this apart for me? g? on any given line in vim looks like it rotates characters though some sequence... :s

share|improve this question
up vote 4 down vote accepted

The task is to rot13 the first column of letters so that they match the word after for; from there it's rather obvious that the top solutions perform the equivalent of a rot13 in one way or another. If we leave out everything we know that is unrelated to rot13 or, at least, changing text… what are we left with?

Let's break the command in smaller chunks:

  • \1 is visual-block mode, nothing to do with rot13 or changing text.

  • \2 extends the visual-block selection to the last line of the buffer, again, nothing to do with rot13 or changing text.

  • \3 is… what?

  • \4 writes and closes the buffer, again, nothing to do with rot13 or changing text.

After all that, g? (the remaining chunk) is the only part of this command that we don't know and that could have something to do with changing text or, maybe, rot13. Given the high rank of the solution and the unbelievable terseness of g?, the probabilities that it does precisely what is asked, rot13, are very high.

Or is it?

To make sure that we are on the right track, let's ask Vim:

:h g?

to which Vim responds, in its usual voice:

Rot13 encode {motion} text.

No google, no internet. Only grey matter and Vim; the unbeatable duo!

share|improve this answer

G means "go to the last line". So if you're at the beginning of the file and press


you end up marking the first column of every line. Now


means do a rot13 encryption. This consists of rotating letters 13 points down the alphabet. This extremely weak encryption is used in online forums to hide offensive language, spoilers, and other stuff you don't want people to read unless they realy want to.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .