Real Vim ninjas count every keystroke - do you?

Pick a challenge, fire up Vim, and show us what you got.

Changelog, Rules & FAQ, updates: @vimgolf, RSS.

Your VimGolf key: please sign in

$ gem install vimgolf
$ vimgolf setup
$ vimgolf put 5f4d8ba936f38a000c89afa6

Change double quotes to single quotes, but with a twist

Although this challenge is in the context of a Python function, you don't need to know Python to do this challenge. It is to add contexts and interesting constraints. The file contains a function that prints a multi-line string literal. I wrote the string literal with double quotes, but then I decided to use single quotes instead, and that's your challenge. However, interestingly enough, the string itself contains single and double quotes. This means, inside the string literal, the originally escaped double quotes no longer need to be escaped, but the single quotes now need to be escaped. Note that the triple double quotes in the docstring should be left alone.

Start file
def some_python_function():
    """
    This is a Python docstring. It describes what a function does.
    The triple quotes above and below me do not need to be changed.
    """

    print(
        "The Gryphon added, \"Come, let's hear some of YOUR adventures.\" "
        "\"I could tell you my adventures - beginning from this morning,\" "
        "said Alice a little timidly: \"but it's no use going back to yesterday, "
        "because I was a different person then.\""
    )
End file
def some_python_function():
    """
    This is a Python docstring. It describes what a function does.
    The triple quotes above and below me do not need to be changed.
    """

    print(
        'The Gryphon added, "Come, let\'s hear some of YOUR adventures." '
        '"I could tell you my adventures - beginning from this morning," '
        'said Alice a little timidly: "but it\'s no use going back to yesterday, '
        'because I was a different person then."'
    )

View Diff

8,11c8,11
<         "The Gryphon added, \"Come, let's hear some of YOUR adventures.\" "
<         "\"I could tell you my adventures - beginning from this morning,\" "
<         "said Alice a little timidly: \"but it's no use going back to yesterday, "
<         "because I was a different person then.\""
---
>         'The Gryphon added, "Come, let\'s hear some of YOUR adventures." '
>         '"I could tell you my adventures - beginning from this morning," '
>         'said Alice a little timidly: "but it\'s no use going back to yesterday, '
>         'because I was a different person then."'

Solutions

The best way to learn is to practice. Below, you will find some of the solutions other golfers have entered. To unlock higher ranked solutions, submit your own entry which does as well or better than the solutions you can currently see - climb the ladder!

Check out these helpful resources to improve your Vim skills... Game on.

Unlock 43 remaining solutions by signing in and submitting your own entry
#44 Anil Narayan / @AnilNarayan2013 - Score: 58 - 09/16/20 @ 04:55
:8<CR>qar'$r'v^:s/\%V\\"/"/g<CR>jq3@a:%s/'s/\'s/g<CR>:<Up><Left><Left><Left><Left>\<CR>kjx:x<CR>

0 comments


Created by: @skylerdong

44 active golfers, 214 entries

Leaderboard (lowest score wins):
38
#31 - Yannick / @Yannick88147038

09/03/2020 at 06:57PM

38
#32 - Demian Martinez / @demianuco

12/09/2020 at 09:47PM

38
#33 - Fake Konto / @F4k3K0n70

02/13/2021 at 09:21PM

40
#34 - kyoosiklee / @kyoosiklee

03/29/2021 at 12:04PM

41
#35 - Marcio M Pereira / @iviarcio

09/02/2020 at 02:45PM

43
#36 - quemeraisc / @quemeraisc

11/10/2020 at 03:07PM

44
#37 - Robert Verst / @r_verst

09/01/2020 at 12:57PM

44
#38 - Christ / @Christ46234422

09/05/2020 at 11:15PM

46
#39 - Muffin / @Muffin91707986

09/03/2020 at 09:51PM

46
#40 - fff / @fff51460170

02/21/2021 at 05:28AM

48
#41 - Sebastian W. / @Sebasti91439242

09/01/2020 at 06:52PM

48
#42 - alrito / @alrito6

09/05/2020 at 09:37PM

54
#43 - kafang plays vimgolf / @KafangV

12/17/2020 at 06:48AM

58
#44 - Anil Narayan / @AnilNarayan2013

09/16/2020 at 04:55AM