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 4fa0d2fa2037000001000057

Exchanging Quotes

Sometimes you need to exchange a choice of quotes in some code.

Start file
mystring = 'This quoted string contains \' and is also'
           'surrounded with \' characters.  It is also'
           'a multiline string too'
End file
mystring = "This quoted string contains ' and used to be"
           "surrounded with ' characters.  It is also"
           "a multiline string too"

View Diff

1,3c1,3
< mystring = 'This quoted string contains \' and is also'
<            'surrounded with \' characters.  It is also'
<            'a multiline string too'
---
> mystring = "This quoted string contains ' and used to be"
>            "surrounded with ' characters.  It is also"
>            "a multiline string too"

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 229 remaining solutions by signing in and submitting your own entry
#230 Viktor Jackson / @AntiStalinista - Score: 87 - 05/05/12 @ 03:08
:%s# '# "#g<CR>:<Up><Left><Left><Left><Left><Left><Left><Left><Right><Right><Left><BS><Right>$<Right><Right><Right><CR>u:<Up><Left><Left><Left><BS><CR>:%s$<BS>#\\##g<CR>1G$3bt"3bct"and used to be<Esc>:w<CR>;q<CR>:q<CR>

0 comments


Created by: @jlozinski

230 active golfers, 858 entries

Leaderboard (lowest score wins):
45
#211 - ltn614 / @ltn614

09/21/2015 at 08:58AM

46
#212 - Bart of Denver / @bartofdenver

08/12/2013 at 02:36PM

46
#213 - Gurukandhamoorthi / @Gurukandhamoor1

07/14/2017 at 05:01PM

47
#214 - a / @tztape

05/02/2012 at 09:13AM

47
#215 - tomazur_06 / @tomazur_06

05/03/2012 at 08:39PM

48
#216 - John Whitley / @johnwhitley

05/07/2012 at 09:10PM

48
#217 - Oliver Christ / @0liverChrist

09/25/2013 at 02:46PM

48
#218 - Jin-hyeok Kim / @JinhyeokKim12

04/06/2023 at 01:47AM

49
#219 - Paul Rosenzweig / @p9r

06/01/2012 at 09:06PM

50
#220 - Dave@Highgroove / @HighgrooveDave

05/22/2012 at 07:38PM

53
#221 - Ravi S Sinha / @ambidextrousTx

08/29/2012 at 09:38PM

55
#222 - Pavlo Klets / @p01nt

05/02/2012 at 10:01AM

55
#223 - Chris Brown / @engineercyb

07/31/2012 at 09:09PM

55
#224 - retired account / @retired10072015

08/20/2012 at 10:54AM

56
#225 - Asenar / @asenar

06/02/2012 at 04:10PM

56
#226 - Jan Wedekind / @wedesoft

07/15/2012 at 09:21PM

58
#227 - shahanavaz m / @shahanavazm

03/19/2024 at 01:33AM

61
#228 - Will Furnass / @WillFurnass

05/08/2012 at 01:48PM

70
#229 - Simo Leone / @simo_leone

05/17/2012 at 09:38PM

87
#230 - Viktor Jackson / @AntiStalinista

05/05/2012 at 03:08AM