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

228 active golfers, 851 entries

Leaderboard (lowest score wins):
30
#1 - Urtica dioica / @udioica

01/04/2013 at 11:55PM

30
#2 - Adam Bell / @adamgbell

03/30/2013 at 04:06PM

30
#3 - Petro Тrouq / @zulolosi

06/01/2013 at 02:44AM

30
#4 - John Braxler / @braxler

03/27/2014 at 08:46PM

30
#5 - Ameen P / @Ameen_P1

06/18/2016 at 07:37AM

30
#6 - herbage / @herbage2

12/10/2016 at 07:09AM

30
#7 - sijinyuan / @sijinyuan

03/22/2017 at 02:32PM

30
#8 - Turkey Man / @lvturkeyman

11/23/2017 at 05:39PM

30
#9 - Dax / @zacoxi

12/06/2018 at 03:18AM

30
#10 - alekfed / @alek_fed

04/16/2019 at 02:04PM

30
#11 - Miłosz Łakomy / @foobar01123

01/13/2020 at 04:20PM

30
#12 - Qing Liu / @poeminlash

08/13/2022 at 08:18PM

30
#13 - Remus Dalrymple / @bornintheflames

12/28/2023 at 10:39AM

30
#14 - jeffreymrussell / @jeffreymrussell

03/12/2024 at 12:06PM

30
#15 - Peppa Pig / @PeppaPi95550250

06/13/2024 at 12:16AM

30
#16 - nickGPT / @nickandbro

08/28/2024 at 08:57PM

31
#17 - Mathieu Fortier / @mathieufortier

05/13/2012 at 03:16AM

31
#18 - sgfgdf / @sgfgdf

05/14/2012 at 03:26PM

31
#19 - Federico Galassi / @federicogalassi

05/15/2012 at 06:35AM

31
#20 - Tim Chase / @gumnos

05/17/2012 at 05:17PM

31
#21 - Forrest L Norvell / @othiym23

05/18/2012 at 05:55AM

31
#22 - Justin Love / @wondible

05/30/2012 at 04:05PM

31
#23 - Raúl Jara / @rauljara

07/06/2012 at 07:40PM

31
#24 - Wei Dai / @clvv42

07/12/2012 at 07:57PM

31
#25 - John Piasetzki / @jpiasetz

07/13/2012 at 04:55AM

31
#26 - Kerson Hsiao / @KersonHsiao

08/14/2012 at 07:39AM

31
#27 - Joseph J. Piché / @jjpiche

08/26/2012 at 01:01AM

31
#28 - Conner McDaniel / @connermcd

09/18/2012 at 04:37AM

31
#29 - Vim rocks / @vimrocks

10/07/2012 at 08:15PM

31
#30 - Victor Ramirez / @virako

10/16/2012 at 01:03AM