Real Vim ninjas count every keystroke - do you?

Pick a challenge, fire up Vim, and show us what you got.

Leaderboard, Changelog, Rules & FAQ, updates: @vimgolf, RSS.

Your VimGolf key: please sign in

$ gem install vimgolf
$ vimgolf setup
$ vimgolf put 4d1e825925ba287b2a0000b7

fix typos, reformat and refactor an ActiveRecord model.

Simple case of refactoring ruby code, change camelize word to undescored (vice versa), proper indentation, removing trailing white spaces, etc.

Start file
Class biling_account < active_record::base
  BelongTo 'person'
  validate_presence_of 'name', 'costumer_vault_id'

  def CreditCard
      true if card_type && card_expires_on
  end

  def CardExpired
      if CreditCard
          true if card_expires_on < Time.zone.now
      end
  end
End  
End file
class BillingAccount < ActiveRecord::Base
  belongs_to :person
  validates_presence_of :name, :customer_vault_id

  def credit_card?
    card_type && card_expires_on
  end

  def card_expired?
    card_expires_on < Time.zone.today if credit_card?
  end
end

View Diff

1,3c1,3
< Class biling_account < active_record::base
<   BelongTo 'person'
<   validate_presence_of 'name', 'costumer_vault_id'
---
> class BillingAccount < ActiveRecord::Base
>   belongs_to :person
>   validates_presence_of :name, :customer_vault_id
5,6c5,6
<   def CreditCard
<       true if card_type && card_expires_on
---
>   def credit_card?
>     card_type && card_expires_on
9,12c9,10
<   def CardExpired
<       if CreditCard
<           true if card_expires_on < Time.zone.now
<       end
---
>   def card_expired?
>     card_expires_on < Time.zone.today if credit_card?
14c12
< End  
---
> end

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 25 remaining solutions by signing in and submitting your own entry
#26 Leon Li / @tubieyi - Score: 137 - 12/31/10 @ 20:24
~w~al<Esc>f_x~ww~f_x~ww~jxbbr:bguwftis_<Esc>jas<Esc>wr:wwxwr:llrufurowxjjguiwfci_<Esc>A?<Esc>jI<Esc>hdtcjjjwguwfei_<Esc>A?<Esc>jguiwfci_<Esc>A?<Esc>ddpkhhdtcJbcwtoday<Esc>jddjlD0~ZZ

0 comments

#27 Juan C. Muller / @juancmuller - Score: 137 - 01/01/11 @ 20:58
<C-V>GEuw~al<Esc>f_x~2W~f_xRR<Esc>fb~/T<CR>vcs_t<Esc>jis<Esc>:%s/'\(\w*\)'/:\1/g<CR>fcfcau<Del><Right><Right>o<Del><Esc>/C<CR>~nvc_c<Esc>A?<Esc>+2h3dwn~fEvc_e<Esc>A?<Esc>jdd6h3dw$cawtoday if cr<C-N>?<Esc>jddGA<BS><BS><Esc>ZZ

0 comments

#28 Aurélien Delahaye / @alkove - Score: 139 - 01/01/11 @ 10:24
:%s/'\(\w*\)'/:\1/g<CR>H~w~al<Esc>f_x~2w~<0xc2><0xa0>f_x~2w~+~fTss_t<Esc>jis<Esc>wforufuro2ja?<Esc>FCs_c<Esc>FCrc"ay$j2Xdtc3jw~fEs_e<kEnd>?<Esc>jdd6Xdtc$xxxatoday if <Esc>"apjddj$xx0~ZZ

0 comments

#29 Brendan Taylor / @beect - Score: 141 - 04/26/11 @ 15:47
VGuw~al<Esc>f_x~2w~f_x~2w~jxBr:?t<CR>is_<Esc>jlis<Esc>Wr:wwxwr:llrulllroA<BS><Esc>2jA?<Esc>4hi_<Esc>j04ldtc4jddpjdd3kfefei_<Esc>A?<Esc>j04ldtcWwrT3wlcwtoday<Esc>J/t<CR>li_<Esc>A?<Esc>GA<BS><BS><Esc>:w<BS><BS>ZZ

0 comments

#30 drio / @drio - Score: 150 - 01/12/11 @ 05:27
<C-V>GEuw~al<Esc>f_x~fa~f_x~fb~/T<CR>vcs_t<Esc>jis<Esc>:%s/'\(\w*\)'/:\1/g<CR>fcfcau<Esc>lxfuro/C~<Esc><BS><Esc>/C<CR>~nvc_cA<BS><Esc>A?<Esc>+2h3dwn~fEvc_e<Esc>A?<Esc>jdd6h3dw$cawtoday if cr<C-N>?<Esc>jjdd<Esc>ukddGA<BS><BS><Esc>ZZ

0 comments

#31 Kevin Webster / @rabidpraxis - Score: 158 - 01/02/11 @ 16:17
~w~x2Prlf_x~2w~f_a<Esc>x~fb~w~tTprspl~wqqr:elxqwt_prsw@qw@qForufuro?C<BS><BS>/C<CR>~f<Esc>tCpr_n~$pr?wdtci<BS><BS><Esc>n~fEi_<Esc>l~$a?<Esc>ndddtci<BS><BS><BS><BS><BS><BS><Esc>$cbtoday if<Esc>;ls credit_card?<Esc>jddw~$xxZZ

0 comments

#32 Nick Klauer / @klauern - Score: 178 - 01/01/11 @ 22:01
~w~al<Esc>f_x~ww~f_x~ww~:%s(<BS>/'\(\w*\)'/:\`1<BS><BS>1/g<CR>k~fTxi_<BS>s_t<Esc>jis<Esc>wwwwwlrulllrojjbbw~fCxi_c<Esc>$a?<Esc>jbbbblbjhhd3wjjjll~fExi_e<Esc>$a?<Esc>jddjddklld3ww$hdwdlatoday if credit_card?<Esc>jjb~lllll<BS>D:x<CR>

0 comments

Created by: @ixandidu

32 active golfers, 66 entries

Leaderboard (lowest score wins):
40051_789281885907_29616532_44170636_2091417_n_normal
96
#1 - Conner McDaniel / @connermcd

09/24/2012 at 05:29PM

Q6hrg93p4r3hn56thmd0_normal
97
#2 - Urtica dioica / @udioica

02/16/2013 at 11:59PM

Default_profile_2_normal
98
#3 - Renat Aksitov / @Korvin79

02/29/2012 at 02:12PM

Avatar_normal
101
#4 - Xavier Nayrac / @lkdjiin

12/31/2011 at 08:21AM

Jlove201003sq_normal
102
#5 - Justin Love / @wondible

07/17/2011 at 10:44AM

Me-small_normal
105
#6 - Wei Dai / @clvv42

01/02/2011 at 04:56PM

Adept_normal
106
#7 - Balkoth / @_Balkoth_

01/02/2011 at 01:29AM

Face_icon_normal
108
#8 - Akira Matsuda / @a_matsuda

01/06/2011 at 05:38AM

Twitter_normal
110
#9 - Austin Taylor / @austintaylor

01/01/2011 at 09:39PM

Default_profile_6_normal
112
#10 - William Dunand / @wdunand

11/23/2011 at 10:46PM

Dom-50_normal
116
#11 - dominique pellé / @vimgolfisto

01/05/2011 at 06:58AM

Image_normal
116
#12 - Pete Johns / @johnsyweb

01/12/2011 at 02:51AM

Shiraseon3_normal
117
#13 - Douglas Stockwell / @dstockwell

12/31/2010 at 08:47PM

E55df1cc7d5fdb4ae9bc2afcb9afe7e4_normal
118
#14 - matthewd / @_matthewd

12/31/2010 at 07:46PM

P1000007_normal
118
#15 - h_east (DDD ready) / @h_east

01/04/2011 at 04:14AM

Bc879469f279ee24b7fbdfad7c2216d9_normal
119
#16 - 無ん垢の叫び / @john_ababa

02/23/2012 at 10:58PM

E_normal
120
#17 - Vincent Isambart / @vincentisambart

12/31/2010 at 06:48PM

Untitled_2_normal
122
#18 -  Ikhsan Maulana / @ixandidu

01/14/2011 at 09:52PM

Default_profile_0_normal
123
#19 - Benoît Ryder / @benoitryder

01/03/2011 at 01:49PM

Gintoki_normal
125
#20 - You-Siang Lin / @yslinnctu

12/14/2011 at 01:33AM

6240_139454607906_723872906_3271730_5845230_n_normal
126
#21 - Alain Gilbert / @alain_gilbert

12/31/2010 at 06:40PM

Bunnies_normal
127
#22 - Trevor Powell / @DoomedBunnies

12/01/2011 at 04:56PM

T_e_normal
129
#23 - Tim Chase / @gumnos

01/13/2011 at 05:15PM

Default_profile_3_normal
129
#24 - Emeric Dupont / @stucule

08/23/2011 at 10:03PM

Uwe_horns_by_joao_normal
135
#25 - Dave / @zzdave13

07/25/2011 at 01:52PM

Default_profile_5_normal
137
#26 - Leon Li / @tubieyi

12/31/2010 at 08:24PM

Img_0830_normal
137
#27 - Juan C. Muller / @juancmuller

01/01/2011 at 08:58PM

Default_profile_4_normal
139
#28 - Aurélien Delahaye / @alkove

01/01/2011 at 10:24AM

6948ecc2a8eec5fede87bb12229b32d0_normal
141
#29 - Brendan Taylor / @beect

04/26/2011 at 03:47PM

29ed1f20888463b3b72bd9fed88a79b8_normal
150
#30 - drio / @drio

01/12/2011 at 05:27AM

Rp_logo_plain_normal
158
#31 - Kevin Webster / @rabidpraxis

01/02/2011 at 04:17PM

Photo_142_normal
178
#32 - Nick Klauer / @klauern

01/01/2011 at 10:01PM