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 50bda7a73645b3000200004b

lamb had a little Mary

"Mary" and "lamb" are swapped. Unswap them. Fast as you can.

Start file
lamb had a little Mary,
Whose fleece was white as snow.
And everywhere that lamb went,
The Mary was sure to go.

It followed her to school one day,
Which was against the rule.
It made the children laugh and play,
To see a Mary at school.

And so the teacher turned it out,
But still it lingered near,
And waited patiently about,
Till lamb did appear.

"Why does the Mary love lamb so?"
The eager children cry.
"Why, lamb loves the Mary, you know."
The teacher did reply.
End file
Mary had a little lamb,
Whose fleece was white as snow.
And everywhere that Mary went,
The lamb was sure to go.

It followed her to school one day,
Which was against the rule.
It made the children laugh and play,
To see a lamb at school.

And so the teacher turned it out,
But still it lingered near,
And waited patiently about,
Till Mary did appear.

"Why does the lamb love Mary so?"
The eager children cry.
"Why, Mary loves the lamb, you know."
The teacher did reply.

View Diff

1c1
< lamb had a little Mary,
---
> Mary had a little lamb,
3,4c3,4
< And everywhere that lamb went,
< The Mary was sure to go.
---
> And everywhere that Mary went,
> The lamb was sure to go.
9c9
< To see a Mary at school.
---
> To see a lamb at school.
14c14
< Till lamb did appear.
---
> Till Mary did appear.
16c16
< "Why does the Mary love lamb so?"
---
> "Why does the lamb love Mary so?"
18c18
< "Why, lamb loves the Mary, you know."
---
> "Why, Mary loves the lamb, you know."

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 112 remaining solutions by signing in and submitting your own entry
#113 Etienne Tremel / etiennetremel - Score: 39 - 02/20/16 @ 21:31
:%s/lamb/Mary/g<CR>fM*cwlamb<Esc>nn.nn.n.nn.ZZ

0 comments


#114 joe di castro / joe_di_castro - Score: 40 - 12/04/12 @ 22:25
:%s/lamb/Z/|%s/Mary/lamb/|%s/Z/Mary/<CR>ZZZ

0 comments


#115 Peter Xiao / PterXiao - Score: 40 - 01/23/13 @ 05:04
:%s/Mary/Z<CR>:#<BS>%s/lamb/Mary<CR>:%s/Z/lamb<CR>ZZ

0 comments


#116 Matt Robbins / mcrmfc - Score: 40 - 04/21/13 @ 21:12
:%s/lamb/_/|%s/Mary/lamb/|%s/_/Mary/<CR>ZZZ

0 comments


#117 RobertT / techrt2050 - Score: 40 - 07/18/13 @ 06:06
:g/lamb/s//Mary<CR>/M<CR>ncwlamb<Esc>2n.2n.n.2n.ZZ

0 comments


#118 Hachez Floran / FloranHachez - Score: 40 - 09/03/13 @ 20:52
<CR>:%s/lamb/#/|%s/Mary/lamb/|%s/#/Mary<CR>ZZZ

0 comments


#119 Django Janny / keltroth - Score: 41 - 12/08/12 @ 16:10
:%s/lamb/Z/|%s/Mary/lamb/|%s/Z/Mary/<CR>::x<CR>

0 comments


#120 Gabutero / wizmokeri - Score: 41 - 04/07/14 @ 05:27
:<Up>%s/lamb/x/|%s/Mary/lama<BS>b/|%s/x/Mary<CR>ZZ

0 comments


#121 Alex J. Ahraus / fanaugen - Score: 41 - 10/22/15 @ 16:52
:%s/lamb/_/|%s/Mary/lamb/|%s/_/Mary<CR>::wq<CR>

0 comments


#122 Liam Chimes / ChimesLiam - Score: 41 - 05/02/18 @ 12:29
:%s/lamb/x/|%s/Mary/lamb/|%s/x/Mary<CR>::wq<CR>

0 comments


#123 Garrett Oreilly / garrett_oh - Score: 43 - 02/14/13 @ 01:48
:%s/lamb/X/g|%s/Mary/lamb/g|%s/X/Mary/g<CR><CR>ZZ

0 comments


#124 Jonathan Karlsson / karlsjona - Score: 43 - 05/07/13 @ 08:28
*qqncwx<Esc>q4@q:%s/Mary/lamb/g<CR>:%s/x/Mary/g<CR>ZZ

0 comments


#125 William Ott / oddalot - Score: 43 - 04/11/15 @ 23:24
:%s/lamb/@/g|%s/Mary/lamb/g|%s/@/Mary/g<CR><CR>ZZ

0 comments


#126 Andrew Michaud / andrewjmichaud - Score: 43 - 09/05/15 @ 01:54
VG:s/lamb/q<CR>Vgg:s/Mary/lamb<CR>Vgg:s/q/Mary<CR>ZZ

0 comments


#127 BJ Neilsen / localshred - Score: 44 - 12/04/12 @ 15:53
:%s/lamb/Z/g<CR>:%s/Mary/lamb/g<CR>:%s/Z/Mary/g<CR>ZZ

0 comments


#128 A R / arusso23 - Score: 44 - 12/22/12 @ 08:46
:%s/Mary/z/g<CR>:%s/lamb/Mary/g<CR>:%s/z/lamb/g<CR>ZZ

0 comments


#129 Patrick Pitoscia / Patrick03960431 - Score: 44 - 08/11/14 @ 02:01
:%s/lamb/z/g<CR>:%s/Mary/lamb/g<CR>:%s/z/Mary/g<CR>ZZ

0 comments


#130 Justin Knag / justinknag - Score: 44 - 08/28/14 @ 13:04
:%s/Mary/z/g<CR>:%s/lamb/Mary/g<CR>:%s/z/lamb/g<CR>ZZ

0 comments


#131 Rolf Vreijdenberger / 3l33th4x0r - Score: 44 - 07/26/17 @ 19:51
:%s/lamb/-/g<CR>:%s/Mary/lamb/g<CR>:%s/-/Mary/g<CR>ZZ

0 comments


#132 c0llision / 0xc0llision - Score: 44 - 01/28/18 @ 14:16
:%s/lamb/-/g<CR>:%s/Mary/lamb/g<CR>:%s/-/Mary/g<CR>ZZ

0 comments


#133 Oliver Christ / 0liverChrist - Score: 46 - 09/25/13 @ 15:01
:%s/lamb/<0xc3><0xb6>/g<CR>:%s/Mary/lamb/g<CR>:%s/<0xc3><0xb6>/Mary/g<CR>ZZ

0 comments


#134 Tj / yrddy - Score: 48 - 08/19/14 @ 07:02
:%s/lamb/cc/g<CR>:%s/Mary/lab<BS>mb/g<CR>:%s/cc/Mary/g<CR>ZZ

0 comments


#135 Chirag Tailor / ctailor2 - Score: 49 - 01/27/14 @ 07:25
:%s/lamg<BS>b/#/|<BS>1<BS>|%/<BS>s/Mary/lamb/|%s/#/Mary<CR>::wq<CR>

0 comments


#136 Pradeep Kumar / pradeep6kumar - Score: 51 - 01/19/13 @ 04:00
:%s/lamb/Mary1/g|%s/\<Mary><BS>\>/lamb1/g|%s/\d//g<CR><CR>ZZ

0 comments


#137 wtnb / _kenichirow - Score: 57 - 04/01/13 @ 17:10
:%s/Mary/_/g<CR>:%s/lamb/Mary/g<CR>:<Up><Up><BS><BS><BS><BS><BS><BS><BS><BS>_/lambg/<BS><BS>/g<CR>:wq<CR>

0 comments


#138 Toto l'haricot / nico_le_terribl - Score: 66 - 12/26/12 @ 09:35
:%s<0xc2><0xa7><BS><0xc2><0xa7>m<BS><BS>/alm<BS><BS><BS>lamb/Mary<BS><BS><BS><BS>aza<CR>:%s/Ma<Tab><BS>ry/lamb<CR>:%s/aza/Mary<CR>ZZ

0 comments


#139 spike grobstein / spike666 - Score: 69 - 05/24/13 @ 21:31
:%s/\v(Mary|lamb)/\={'Mary':'lamb','lamb':'Mary'}[submatch(0)]/g<CR>:wq<CR>

0 comments


#140 infinitekh / infinitekh - Score: 121 - 12/11/12 @ 16:29
:%s/lamb/temmmmm<BS><BS><BS><BS><BS><BS><BS>tteemmpp/g<CR>:<Up><Left><Right><BS><BS><BS><BS><BS><BS><BS><BS><BS><BS><BS><BS><BS><BS><BS>Mary/lamb/g<CR>:<Up><Up><Left><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><BS><BS><Left><Left><Left><Left><Left><Left><Left><Left><BS><BS><BS><BS><BS><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right>/Mary/g<CR>:wq<CR>

0 comments


Created by: udioica

140 active golfers, 447 entries

Leaderboard (lowest score wins):
16
#1 - Kerson Hsiao / KersonHsiao

12/04/2012 at 04:34PM

16
#2 - Conner McDaniel / connermcd

12/04/2012 at 05:21PM

16
#3 - Urtica dioica / udioica

12/04/2012 at 11:20PM

16
#4 - Yann Moisan / YannMoisan

02/10/2013 at 01:37PM

16
#5 - Chasetopher / chasetopherlee

04/29/2013 at 04:45AM

16
#6 - Petro Тrouq / zulolosi

05/11/2013 at 10:10PM

16
#7 - wushexu / wushexu

05/25/2013 at 06:15AM

16
#8 - Marco Hinz / _mhinz_

05/26/2013 at 11:58AM

16
#9 - Andrew O'Neill / AndroidOatmeal

02/19/2014 at 03:47PM

16
#10 - John Braxler / braxler

04/07/2014 at 07:54PM

16
#11 - ZorgroZ / ZorgroZ

04/14/2014 at 10:41PM

16
#12 - retired account / retired10072015

07/01/2014 at 08:35PM

16
#13 - I / ForgetIt17

08/20/2014 at 01:52PM

16
#14 - Tim Grebien / tiggg

02/21/2017 at 03:37PM

16
#15 - Daniel / Daniel00288663

04/03/2017 at 10:05AM

16
#16 - BarbaJol / drpproteus

01/10/2018 at 04:39PM

17
#17 - Alec Goebel / zego5360

01/04/2013 at 04:43AM

17
#18 - Steve Tjoa / stevetjoa

07/18/2013 at 06:21PM

18
#19 - Julius Pfrommer / dlctr

03/02/2013 at 08:21PM

25
#20 - Marcin Sza / coot_

12/04/2012 at 06:56PM

25
#21 - Aniket Schneider / shaydwyrm

12/08/2012 at 07:25AM

25
#22 - A / a_akessler

12/10/2012 at 06:45PM

25
#23 - Édouard M'tou / DouardM

12/19/2012 at 03:02PM

25
#24 - Chris Trombley / ctrombley

01/28/2013 at 05:44PM

25
#25 - Trevor Powell / DoomedBunnies

04/11/2013 at 02:46AM

25
#26 - Bradd Szonye / bszonye

07/13/2013 at 01:33AM

25
#27 - powertomato / powertomato

07/22/2013 at 11:50AM

25
#28 - Dom Armstrong / dom_cycleface

10/01/2013 at 01:04PM

25
#29 - Casey Dwyer / caseydwyer

11/04/2013 at 04:30AM

25
#30 - US Dollar Price / USDollarPrice

11/06/2013 at 07:03AM