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):
38
#151 - JustGage / @JustGage

09/03/2012 at 03:10PM

38
#152 - Justin / @justinjaffray

05/17/2013 at 03:17PM

38
#153 - brett / @brettyukich

09/21/2013 at 03:12AM

38
#154 - Eric Potter / @pottereric

12/20/2013 at 02:44PM

38
#155 - Jason L. Shiffer / @zerotao

01/29/2014 at 01:56PM

38
#156 - Ali El Amine / @Allouch95

02/07/2014 at 03:15PM

38
#157 - Patrick Pitoscia / @Patrick03960431

08/07/2014 at 10:12PM

38
#158 - RockerZZY / @rocker_zzy

06/20/2020 at 11:54PM

38
#159 - gpfl0712 / @gpfl0712

04/14/2024 at 01:12PM

39
#160 - vall / @provall1

05/04/2012 at 10:18AM

39
#161 - Tyler B / @DuderB

05/17/2012 at 01:54AM

39
#162 - Jason Rudolph / @jasonrudolph

05/17/2012 at 11:28PM

39
#163 - jimdev / @jimdev2

05/25/2012 at 08:42AM

39
#164 - Ilya Strukov / @i1ey

05/26/2012 at 07:19AM

39
#165 - Benjamin Sergeant / @bsergean

06/05/2012 at 04:39AM

39
#166 - buz / @buzbone

06/15/2012 at 02:13AM

39
#167 - utopiah / @utopiah

06/18/2012 at 12:56PM

39
#168 - Benoit Thiell / @benoitthiell

07/23/2012 at 02:25PM

39
#169 - Greg Sexton / @greg_sexton

08/05/2012 at 08:15PM

39
#170 - Justin Le / @mstk

07/25/2013 at 07:02AM

39
#171 - Juan Luis / @rufianw

07/03/2014 at 03:14AM

39
#172 - Walker Boh / @walker_boh

10/13/2015 at 08:24AM

39
#173 - Gerald Tilma / @GeraldTilma

10/21/2015 at 02:07AM

39
#174 - Nicolas Nistal / @niconistal

11/19/2015 at 08:04PM

39
#175 - xiaoao1024 / @xiaoao1024

05/06/2024 at 11:24AM

39
#176 - Kristóf Cserpes / @KriCse

10/23/2024 at 11:25AM

40
#177 - Richard Ramsden / @rramsden

05/07/2012 at 09:50PM

40
#178 - Neal Lindsay / @neall

05/10/2012 at 10:23PM

40
#179 - learninghang / @learninghang

05/17/2012 at 03:54AM

40
#180 - Chris Dahms / @zentrified

05/19/2012 at 11:10PM