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

Cleanining up 80 column concatenated text

1. Put the whole query on one line, remove the concatenation operators 2. Remove the double spaces that appear a few times in the query 3. Use string-interpolated variable statementPid rather than the ugly concatenation

Start file
$atres = sqlStatement("select f.name,f.street,f.city,f.state,f.postal_code from facility f " .
 
" left join users u on f.id=u.facility_id " .
 
" left join  billing b on b.provider_id=u.id and b.pid = '".$stmt['pid']."' " .
 
" where  service_location=1");
$row
= sqlFetchArray($atres);
End file
$atres = sqlStatement("select f.name,f.street,f.city,f.state,f.postal_code from facility f left join users u on f.id=u.facility_id left join billing b on b.provider_id=u.id and b.pid = $statementPid where service_location=1");
$row
= sqlFetchArray($atres);

View Diff

1,4c1
< $atres = sqlStatement("select f.name,f.street,f.city,f.state,f.postal_code from facility f " .
<   " left join users u on f.id=u.facility_id " .
<   " left join  billing b on b.provider_id=u.id and b.pid = '".$stmt['pid']."' " .
<   " where  service_location=1");
---
> $atres = sqlStatement("select f.name,f.street,f.city,f.state,f.postal_code from facility f left join users u on f.id=u.facility_id left join billing b on b.provider_id=u.id and b.pid = $statementPid where service_location=1");

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 78 remaining solutions by signing in and submitting your own entry
#79 Alberto Alcaraz / @Subastkar - Score: 88 - 06/25/12 @ 21:21
:%s/" \.\n  "<CR>:%s'<BS>/  ' <BS><BS>/  <BS>/g<CR>:%s/'".$\<stmt\>\['\<pid\>'\]."'/$statementPid/g<CR>:q<BS>wq<CR>

0 comments


Created by: @Salshammath

79 active golfers, 203 entries

Leaderboard (lowest score wins):
35
#31 - William Dunand / @wdunand

08/03/2012 at 06:00AM

38
#32 - Kerson Hsiao / @KersonHsiao

06/24/2012 at 07:49AM

38
#33 - Ilya Ermolin / @ermolinis

06/26/2012 at 06:34PM

38
#34 - Paul McDowell / @etothepi16

06/16/2024 at 05:39PM

39
#35 - Tibor Claassen / @codebeige

06/23/2012 at 09:34PM

39
#36 - Corentin / @codl

04/13/2013 at 06:21AM

41
#37 - Maksim S. / @waynesayonara

09/02/2012 at 02:16PM

41
#38 - Joonas Pihlajamaa / @jokkebk

03/04/2014 at 07:40AM

42
#39 - Vincent Beffara / @vbeffara

06/24/2012 at 11:51AM

42
#40 - Øystein Walle / @oysteinwalle

06/25/2012 at 08:28PM

42
#41 - Trevor Powell / @DoomedBunnies

07/04/2012 at 06:29AM

42
#42 - James / @Dronak

09/19/2014 at 11:38PM

43
#43 - brett / @brettyukich

09/23/2013 at 10:58AM

44
#44 - Dave / @zzdave13

07/02/2012 at 10:01PM

44
#45 - tmr / @tmr314

09/04/2012 at 10:43PM

44
#46 - Underhill Labs / @underhilllabs

11/02/2012 at 01:30AM

44
#47 - cj / @cj01101

08/27/2013 at 02:31AM

44
#48 - RockerZZY / @rocker_zzy

06/08/2020 at 02:29AM

45
#49 - Glen / @Glen_S

08/04/2012 at 09:12AM

45
#50 - Alex Tercete / @alextercete

08/24/2012 at 06:07AM

46
#51 - Ram Tamtam / @ramtamtamtam

07/02/2014 at 02:32PM

47
#52 - mlu / @_mlu

07/27/2012 at 08:06AM

47
#53 - Salvador / @smastermind

08/17/2012 at 02:50PM

47
#54 - Eric Potter / @pottereric

05/31/2013 at 01:56PM

48
#55 - Mahefa Randimbisoa / @DotMG

07/04/2012 at 11:07AM

48
#56 - Chris Brown / @engineercyb

07/12/2012 at 09:10PM

48
#57 - Michael Limiero / @michaellimiero

08/13/2012 at 10:03PM

48
#58 - Stephen Fiorelli / @sfiorell2

08/22/2012 at 07:42PM

48
#59 - n0nick / @n0nick

11/19/2012 at 02:13PM

48
#60 - Oliver Christ / @0liverChrist

10/07/2013 at 09:10PM