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 106 remaining solutions by signing in and submitting your own entry
#107 Robert Robertson / RobertC3228687 - Score: 39 - 07/01/15 @ 17:31
:%s/Mary/+/|%s/lamb/Mary/|%s/+/lamb/|x<CR>

0 comments

#108 Gerald Tilma / GeraldTilma - Score: 39 - 10/22/15 @ 02:33
:%s/lamb/x/|%s/Mary/lamb/|%s/x/Mary/|x<CR>

0 comments

#109 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

#110 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

#111 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

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

0 comments

#113 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

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

0 comments

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

0 comments

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

0 comments

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

0 comments

#118 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

#119 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

#120 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

#121 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

#122 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

#123 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

#124 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

#125 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

#126 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

#127 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

#128 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

#129 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

#130 kenichiro watanabe / _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

#131 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

#132 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

#133 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

133 active golfers, 422 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 - Chase Stubblefield / sterlingchase

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

17
#16 - Alec Goebel / zego5360

01/04/2013 at 04:43AM

17
#17 - Steve Tjoa / stevetjoa

07/18/2013 at 06:21PM

18
#18 - Julius Pfrommer / dlctr

03/02/2013 at 08:21PM

25
#19 - Marcin Sza / coot_

12/04/2012 at 06:56PM

25
#20 - Aniket Schneider / shaydwyrm

12/08/2012 at 07:25AM

25
#21 - A / a_akessler

12/10/2012 at 06:45PM

25
#22 - Édouard M'tou / DouardM

12/19/2012 at 03:02PM

25
#23 - Chris Trombley / ctrombley

01/28/2013 at 05:44PM

25
#24 - Trevor Powell / DoomedBunnies

04/11/2013 at 02:46AM

25
#25 - Bradd Szonye / bszonye

07/13/2013 at 01:33AM

25
#26 - powertomato / powertomato

07/22/2013 at 11:50AM

25
#27 - Dom Armstrong / dom_cycleface

10/01/2013 at 01:04PM

25
#28 - Casey Dwyer / caseydwyer

11/04/2013 at 04:30AM

25
#29 - US Dollar Price / USDollarPrice

11/06/2013 at 07:03AM

25
#30 - jgpaiva / jgpaiva

01/31/2014 at 06:17PM

25
#31 - mark0829 / mark0829

03/05/2015 at 06:24AM

25
#32 - pftb12345 / pftb12345

04/11/2015 at 05:18PM

25
#33 - Clark DuVall / theclarkatron

05/22/2015 at 06:21AM

25
#34 - Dimitar Dimitrov / kurkale6ka

03/23/2016 at 02:58PM

29
#35 - N / nymph192

02/11/2013 at 09:23PM

31
#36 - h_east (トロッコ6個) / h_east

12/04/2012 at 01:20PM

31
#37 - Joel Elkins / dice_tea

03/04/2013 at 04:34AM

31
#38 - Ram Tamtam / ramtamtamtam

07/17/2014 at 10:19AM

32
#39 - 無ん垢の叫び / john_ababa

12/09/2012 at 10:26AM

32
#40 - banana / sparkleseed

12/23/2012 at 05:18AM

32
#41 - Global Maquereau / GlobalMaquereau

12/24/2012 at 12:53PM

32
#42 - Tobias Praetsch / tpraetsch

02/17/2013 at 09:06PM

32
#43 - Tyler / tylerbindon

04/03/2013 at 04:06AM

32
#44 - Justin / justinjaffray

04/23/2013 at 04:45PM

32
#45 - Nathan / NathanHarperoni

06/01/2013 at 04:03AM

32
#46 - Andrew Crites / ExplosionPills

09/14/2013 at 03:51AM

32
#47 - Domingue Justin / _jdomingue

12/24/2013 at 04:51AM

32
#48 - Quota / Quotad

01/31/2014 at 09:45AM

32
#49 - Joonas Pihlajamaa / jokkebk

02/20/2014 at 10:54AM

32
#50 - Brian Olpin / bolpin

03/29/2014 at 04:53AM

33
#51 - Martin Galpin / MartinRGalpin

08/22/2015 at 10:35AM

34
#52 - Hubba / HubbaBubbaFett

12/07/2012 at 08:59PM

34
#53 - Panupan S. / lionpeal

01/17/2013 at 11:47PM

34
#54 - Kai Yuan / kentyuan

02/22/2013 at 01:31AM

34
#55 - cj / cj01101

08/08/2013 at 11:59AM

34
#56 - James / Dronak

08/29/2013 at 03:34PM

34
#57 - Paul Federspiel / parobalth

10/23/2013 at 09:04PM

34
#58 - Patrick Oscity / der_padde

02/11/2014 at 02:00PM

34
#59 - eBrnd / eBrnd

11/05/2014 at 09:23PM

34
#60 - Liam Thurston / lthurston188

08/18/2015 at 05:42AM

34
#61 - Walker Boh / walker_boh

10/14/2015 at 03:34PM

34
#62 - tPenguinLTG / tpenguinltg

05/01/2016 at 11:13PM

35
#63 - Asmund Liseth / Asmund_L

12/23/2012 at 11:47PM

35
#64 - Steven Herbst / transistorman

02/25/2013 at 12:28AM

35
#65 - Nathan Fisher / natbobc

03/16/2013 at 02:26AM

35
#66 - David Yan / david_yan

04/18/2013 at 10:51AM

35
#67 - Bunwut Tson / NbTson

09/01/2013 at 10:31PM

35
#68 - brett / brettyukich

09/21/2013 at 08:35AM

35
#69 - Tom Cammann / tea_sea

05/13/2014 at 08:40AM

35
#70 - Caek / Caek_

07/07/2014 at 02:50AM

36
#71 - Daniel Lundin / danielundin

12/04/2012 at 09:15AM

36
#72 - Eric Andres / eric_m_andres

12/04/2012 at 05:57PM

36
#73 - Lieven Keersmaekers / LievenKeersmaek

12/04/2012 at 06:03PM

36
#74 - Pawel Obrok / mrYapee

12/05/2012 at 07:45AM

36
#75 - Chris Maguire / chriswmaguire

12/05/2012 at 04:42PM

36
#76 - Mikhail / styx_mp

12/05/2012 at 07:13PM

36
#77 - Casey Robinson / rampant_monkey

12/05/2012 at 09:12PM

36
#78 - František Hartman / frant_hartm

12/06/2012 at 03:30PM

36
#79 - Michael / patheticpat

12/16/2012 at 05:59PM

36
#80 - John GraphFrog / FragOnly

12/17/2012 at 03:41PM

36
#81 - Tamás Kárándi / tkarandi

12/17/2012 at 11:08PM

36
#82 - n0nick / n0nick

12/19/2012 at 01:08PM

36
#83 - John Papanastasiou / JohnPapps

01/12/2013 at 07:31PM

37
#84 - Sean Anderson / sean_anderson

04/29/2013 at 10:20AM

38
#85 - Runar / runarfu

12/04/2012 at 07:56AM

38
#86 - Arun / UArunKumar

12/04/2012 at 07:46PM

38
#87 - Johnny Hoang / JohnnyHoang

12/04/2012 at 10:49PM

38
#88 - Fred Nias / frednias

12/06/2012 at 12:52PM

38
#89 - Jon Moshier / jonmoshier

12/06/2012 at 11:30PM

38
#90 - mnx / mnxx

12/17/2012 at 11:28PM

38
#91 - Marko Tibold / markotibold

12/24/2012 at 12:46AM

38
#92 - XGOLFER / vimg0lfer

01/04/2013 at 10:51PM

38
#93 - Eric Potter / pottereric

05/27/2013 at 08:02PM

38
#94 - Joe Sullivan / itsjoesullivan

06/19/2013 at 06:04AM

38
#95 - moo goo / m00g000

07/01/2013 at 07:40PM

38
#96 - Kevin James / KevinKarruthers

11/20/2013 at 09:12PM

38
#97 - Fnord Everywhere / FnordE

12/16/2013 at 12:49PM

38
#98 - Mauro Persano / fzort

11/16/2014 at 02:54AM

38
#99 - Brian Hall / _bruab_

03/29/2017 at 03:18PM

39
#100 - Roland Schatz / fl_Overmind

12/14/2012 at 02:16PM

39
#101 - CY / wongcy0

01/28/2013 at 06:51AM

39
#102 - Christopher Harrison / Xophmeister

01/29/2013 at 02:32PM

39
#103 - Neil Pahl / neildaemond

02/23/2013 at 06:47PM

39
#104 - Joshua Draper / JoshuaBDraper

05/25/2013 at 08:14PM

39
#105 - gary.klindt@googlema / garstekli

12/01/2013 at 07:40PM

39
#106 - David Tabachnikov / davidtab

09/30/2014 at 01:29PM

39
#107 - Robert Robertson / RobertC3228687

07/01/2015 at 05:31PM

39
#108 - Gerald Tilma / GeraldTilma

10/22/2015 at 02:33AM

39
#109 - Etienne Tremel / etiennetremel

02/20/2016 at 09:31PM

40
#110 - joe di castro / joe_di_castro

12/04/2012 at 10:25PM

40
#111 - Peter Xiao / PterXiao

01/23/2013 at 05:04AM

40
#112 - Matt Robbins / mcrmfc

04/21/2013 at 09:12PM

40
#113 - RobertT / techrt2050

07/18/2013 at 06:06AM

40
#114 - Hachez Floran / FloranHachez

09/03/2013 at 08:52PM

41
#115 - Django Janny / keltroth

12/08/2012 at 04:10PM

41
#116 - Anna Gabutero / agabutero

04/07/2014 at 05:27AM

41
#117 - Alex J. Ahraus / fanaugen

10/22/2015 at 04:52PM

43
#118 - Garrett Oreilly / garrett_oh

02/14/2013 at 01:48AM

43
#119 - Jonathan Karlsson / karlsjona

05/07/2013 at 08:28AM

43
#120 - William Ott / oddalot

04/11/2015 at 11:24PM

43
#121 - Andrew Michaud / andrewjmichaud

09/05/2015 at 01:54AM

44
#122 - BJ Neilsen / localshred

12/04/2012 at 03:53PM

44
#123 - A R / arusso23

12/22/2012 at 08:46AM

44
#124 - Patrick Pitoscia / Patrick03960431

08/11/2014 at 02:01AM

44
#125 - Justin Knag / justinknag

08/28/2014 at 01:04PM

46
#126 - Oliver Christ / 0liverChrist

09/25/2013 at 03:01PM

48
#127 - Tj / yrddy

08/19/2014 at 07:02AM

49
#128 - Chirag Tailor / ctailor2

01/27/2014 at 07:25AM

51
#129 - Pradeep Kumar / pradeep6kumar

01/19/2013 at 04:00AM

57
#130 - kenichiro watanabe / _kenichirow

04/01/2013 at 05:10PM

66
#131 - Toto l'haricot / nico_le_terribl

12/26/2012 at 09:35AM

69
#132 - spike grobstein / spike666

05/24/2013 at 09:31PM

121
#133 - infinitekh / infinitekh

12/11/2012 at 04:29PM