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 55 remaining solutions by signing in and submitting your own entry
#56 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

56 active golfers, 309 entries

Leaderboard (lowest score wins):
22
#1 - Jon Krause / @jkrause314

09/01/2020 at 01:38AM

22
#2 - Jonáš Šerých / @serycjon

09/01/2020 at 09:01PM

22
#3 - Martin Bielik / @mabielik

09/04/2020 at 10:44PM

22
#4 - 刘宏亮 / @AkeyCoy

09/08/2020 at 10:11AM

22
#5 - John Braxler / @braxler

09/09/2020 at 04:14PM

22
#6 - Ravi S Sinha / @ambidextrousTx

09/15/2020 at 01:49AM

22
#7 - Mario Olofo / @mario_olofo

09/16/2020 at 12:33PM

22
#8 - Ivan Kwong / @IvanKwong5

09/27/2020 at 10:26AM

22
#9 - lamtt77 / @lamtt77

10/10/2020 at 02:02AM

22
#10 - hepebexè / @hepebexe

11/18/2020 at 06:51PM

22
#11 - chocolate / @chocola81394123

11/24/2020 at 06:56AM

22
#12 - Jung Yeon Park / @park_jungy

01/08/2021 at 07:03PM

22
#13 - roudens / @roudens2

01/09/2021 at 11:30AM

22
#14 - A A A / @37fatos

01/13/2021 at 03:07PM

22
#15 - der tanzbaer / @der_tanzbaer

03/13/2021 at 06:07PM

22
#16 - Arya Kumar / @SusSquirrel

06/04/2021 at 10:57PM

22
#17 - Roman Privalov / @RomanPrivalov

08/25/2021 at 04:38AM

22
#18 - Sammit / @somemeatjain

01/26/2022 at 04:42PM

22
#19 - quemeraisc / @quemeraisc

05/15/2022 at 03:49PM

22
#20 - Lory / @Lory46845742

07/23/2022 at 08:45AM

22
#21 - Topvimgolf Score / @topvimgolfscore

09/21/2023 at 11:16AM

22
#22 - Aly Thobani / @alythobani

05/29/2024 at 12:47AM

22
#23 - Peppa Pig / @PeppaPigSg

06/13/2024 at 12:52AM

22
#24 - nickGPT / @nickandbro

08/24/2024 at 04:27AM

23
#25 - Vinícius Hoyer / @viniciushoyer

09/04/2020 at 01:47PM

23
#26 - mstronam / @mstronam

10/04/2020 at 06:19AM

23
#27 - naka / @nak38223985244

11/18/2023 at 07:11AM

24
#28 - TheSemicolon / @the_semicolon_

09/09/2020 at 08:31AM

24
#29 - Luoyb / @Luoyb

10/25/2023 at 06:39AM

25
#30 - "Smylers" / @Smylers2

09/01/2020 at 06:05AM