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):
49
#61 - captain_morgan / @captain_morgan

06/24/2012 at 01:24AM

49
#62 - Sebastian Korten / @FlashKorten

07/20/2012 at 03:42PM

50
#63 - ltn614 / @ltn614

10/08/2015 at 09:51AM

50
#64 - Turkey Man / @lvturkeyman

01/02/2018 at 06:27AM

50
#65 - shahanavaz m / @shahanavazm

03/21/2024 at 06:56PM

52
#66 - Groovy / @groovy9

03/09/2019 at 04:20PM

53
#67 - Stephen Crosby / @stevecrozz

07/19/2012 at 05:20AM

53
#68 - Stefan Schmidt / @stafue

12/06/2013 at 04:33PM

53
#69 - nickGPT / @nickandbro

08/28/2024 at 08:09PM

54
#70 - Reed Riley / @ReedRile

08/11/2012 at 05:55PM

54
#71 - Adelar S. Queiróz / @adelarsq

12/04/2012 at 11:21PM

55
#72 - Mateusz Zawisza / @mateuszzawisza

06/23/2012 at 10:20PM

55
#73 - J Paul Daigle / @philosodad

06/25/2012 at 05:01PM

58
#74 - Juanje Ojeda / @juanjeojeda

07/05/2012 at 02:30AM

60
#75 - Christopher Garvis / @cgarvis

09/10/2012 at 03:47PM

61
#76 - Pandae / @psasqw

06/26/2012 at 12:57PM

65
#77 - Ryan O'Connell / @Salshammath

06/23/2012 at 09:18PM

80
#78 - Sven Koesling / @McSvenster

08/14/2012 at 03:03PM

88
#79 - Alberto Alcaraz / @Subastkar

06/25/2012 at 09:21PM