

Can you solve this TextEditing challenge in less than 5 keystrokes? - Vidura
http://vimgolf.com/challenges/4d1db1b8de2f897c2a00014a

======
tzs
What is a keystroke? For instance, is a control character two keystrokes? How
about a shifted character? Their FAQ and rules page didn't say (or I somehow
missed it).

The way that first comes to mind to do that particular text transform is
(using up arrow notation for control characters):

    
    
        :s/./^M&/g
    

If shifted and control characters count as one keystroke, not two, then that
is 11 characters (^M takes two, because it is entered as ^V ENTER). However,
the leader board currently shows 12 as the best solution, and I'm having a
hard time believing, since I'm not anywhere near being a vim guru, that my
first "off the top of my head" solution could take the lead.

So I would assume that means modifier keys do count. In that case, mine is 14.
Interestingly, no one else has a 14 on the leader board. There are a bunch of
12's, then a 13, then a 16.

Assuming the cursor starts on the first character of the first line, my second
idea is

    
    
        qea<ENTER><ESC>q24@e
    

That would be 12. That's about the limit of my vim-fu. Under 5? Way beyond
me...unless the submitter accidentally linked to the wrong problem!

EDIT: OK, my first attempt above doesn't work. It puts an extra blank line at
the top of the file. (Swapping the order of ^M and & puts an extra blank at
the bottom). The second solution above works, and I was curious enough to see
if I'd guessed the counting rules that I signed up and submitted it, and sure
enough it is 12, and it is the same (up to the name of the macro) as all the
other 12 keystroke solutions. (Although it turns out I didn't guess the rules.
Shifted characters count as one, but it counts whatever you use to save and
exit).

It's interesting to see the names others use for their macro. A lot of people
used 'a' or 'q', and one person used '0'. I'm the only 'e'. I use 'e' for
temporary macros because invocation is easier with 'e': @e is easier, it seems
to me, to type than @a or @q or @0.

EDIT 2: the problem the submission links to is named "Reverse simple
deletion". There is another problem named "Simple deletion" which currently
has a best score of 6.
(<http://vimgolf.com/challenges/4d1d9f55de2f897c2a000103>). I wonder if the
submitter meant to submit that one?

------
dgc
:s/1*/\r/g <return>

11 keystrokes but it adds an additional new line, not sure if that would pass
the test.

~~~
dgc
bah, the earlier poster got both my methods, oh well, teach me to read.

------
nemoniac
On emacs, the immediately obvious approach takes 11 keystrokes:

C-x ( C-f <return> C-x ) C-u 2 5 C-x e

