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

PHP Array Syntax -> MailChimp Merge Syntax

I recently needed to send an e-mail to our marketing department listing allowed merge tags for our MailChimp campaigns. The allowed merge tags were determined from a PHP array in one of our PHP classes. I transformed the PHP class to MailChimp's syntax and sent the e-mail. It was, however, a long, laborious process. I'm still fairly new to Vim and would love to see how an expert Vim user would tackle one of my own, real-world problems. Thanks and have fun!

Start file
$allowed = array("PIN", "Prefix", "LastName", "FirstName", "MiddleName", 
 
"Address1", "Address2", "City", "State", "Zip", "Country", "phone", "mobile",
 
"Email", "MothersMaiden", "security1_id", "security1_answer",
 
"security2_id", "security2_answer", "BirthDate",
 
"flag1", "DriversLicense", "gender");
End file
*|PIN|*
*|Prefix|*
*|LastName|*
*|FirstName|*
*|MiddleName|*
*|Address1|*
*|Address2|*
*|City|*
*|State|*
*|Zip|*
*|Country|*
*|phone|*
*|mobile|*
*|Email|*
*|MothersMaiden|*
*|security1_id|*
*|security1_answer|*
*|security2_id|*
*|security2_answer|*
*|BirthDate|*
*|flag1|*
*|DriversLicense|*
*|gender|*

View Diff

1,5c1,23
< $allowed = array("PIN", "Prefix", "LastName", "FirstName", "MiddleName",
<   "Address1", "Address2", "City", "State", "Zip", "Country", "phone", "mobile",
<   "Email", "MothersMaiden", "security1_id", "security1_answer",
<   "security2_id", "security2_answer", "BirthDate",
<   "flag1", "DriversLicense", "gender");
---
> *|PIN|*
> *|Prefix|*
> *|LastName|*
> *|FirstName|*
> *|MiddleName|*
> *|Address1|*
> *|Address2|*
> *|City|*
> *|State|*
> *|Zip|*
> *|Country|*
> *|phone|*
> *|mobile|*
> *|Email|*
> *|MothersMaiden|*
> *|security1_id|*
> *|security1_answer|*
> *|security2_id|*
> *|security2_answer|*
> *|BirthDate|*
> *|flag1|*
> *|DriversLicense|*
> *|gender|*

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 149 remaining solutions by signing in and submitting your own entry
#150 Ryan / @Rdgy567889 - Score: 246 - 10/01/23 @ 10:42
dt(4jf)D04j4kxjxxj2xj2xj2x"s<Esc>:s/ <Left><Left><Left>%<Right><Right> <BS>/<BS> /\n<CR><Esc>u:s/<BS><BS>%s/ /\n/g<CR>u/"<BS>:s/ <BS><BS><BS><BS><BS>:s/ /<Left><Left><Left><Left>%<Right><Right><Right><Right>\r/g<CR>kkkdd4j6kdd13kdd:s/"//g<Left><Left><Left><Left><Left><Left>%<CR>/<BS>:s,<BS><BS>%s/,//g<CR>j<C-V>GGggI*|<Esc><Esc>:s/&<BS>^<BS>*<BS>$<Left>,<BS>.<Left><Left><Right><Right><Right><BS><BS>\r/<Left><Left><Left><Left><Left>%<Right><Right><Right><Right><BS>n<Right>|*/g<Left><Left><Left><Right>}<BS>\n<CR>u"<Esc>jk:s<BS>$<BS>%s/^<BS>$.<BS><BS>.$/.<BS><BS><BS><BS><BS><BS>norm A|*<CR>:wq<CR>

0 comments


Created by: @meekish

150 active golfers, 545 entries

Leaderboard (lowest score wins):
46
#121 - James Cash / @jamesnvc

10/19/2011 at 02:46PM

46
#122 - Salvador Tojo Quintela / @SalvadorTojo

10/10/2021 at 06:52AM

46
#123 - steve / @steve35773420

03/04/2023 at 03:16PM

49
#124 - Chaiporn Jaikaeo / @cjaikaeo

11/27/2011 at 05:37PM

50
#125 - Iori ONDA / @120reset

12/14/2011 at 11:14AM

50
#126 - Angela Harms / @angelaharms

01/18/2012 at 12:52AM

51
#127 - Daniel Schierbeck / @dasch

12/06/2011 at 04:30PM

51
#128 - Tom Fetherston / @TomFetherston

01/18/2012 at 04:47AM

51
#129 - shahanavaz m / @shahanavazm

03/16/2024 at 02:16AM

52
#130 - Roman Mašek / @romario333

10/24/2011 at 09:06PM

52
#131 - Gowtham Madhava / @gowthamgowtham

11/02/2011 at 05:34PM

52
#132 - Ethan / @ethanmiller

01/31/2012 at 04:17AM

52
#133 - Scott Schlesier / @sschlesier

02/22/2012 at 06:29AM

52
#134 - じょんあば / @john_ababa

02/28/2012 at 04:04PM

52
#135 - Antoni Villalonga / @friki

08/15/2016 at 06:33PM

53
#136 - 415fox / @415fox

11/08/2011 at 06:10PM

53
#137 - Mattiassich Ákos / @mattiassicha

11/23/2011 at 08:31PM

53
#138 - Martin Liberg / @marreman

02/07/2015 at 07:06PM

53
#139 - POSIX / @po6ix

02/02/2022 at 02:22PM

53
#140 - vimgolfaccfekxh / @vimgolfaccfekxh

10/20/2022 at 01:14AM

54
#141 - Michael / @patheticpat

12/17/2012 at 03:09PM

55
#142 - changling / @Lspacewalker

12/27/2011 at 07:51PM

57
#143 - D A / @7187dd578b325d2

11/24/2011 at 12:25PM

60
#144 - Bruce Woodward / @Bruce_Woodward

10/24/2011 at 10:57AM

62
#145 - Jouko Karvonen / @joukokar

10/22/2011 at 06:42AM

63
#146 - Aviv Ben-Yosef / @avivby

10/20/2011 at 05:34PM

66
#147 - celery rho gamma / @rentalcustard

10/19/2011 at 03:07PM

66
#148 - James Freed / @JamesTFreed

02/02/2012 at 11:26PM

168
#149 - Zee Spencer / @zspencer

01/18/2012 at 12:51AM

246
#150 - Ryan / @Rdgy567889

10/01/2023 at 10:42AM