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

Reformat/Refactor a Golfer Class

A simple case of removing unneeded code and fixing broken indentation.

Start file
class Golfer
     def initialize; end # initialize
  def useless; end;
  
     def self.hello(a,b,c,d)
      puts "Hello #{a}, #{b}, #{c}, #{d}"
   end
end
End file
class Golfer
  def self.hello(*a)
    puts "Hello #{a.join(',')}"
  end
end

View Diff

2,7c2,4
<      def initialize; end # initialize
<   def useless; end;
<   
<      def self.hello(a,b,c,d)
<       puts "Hello #{a}, #{b}, #{c}, #{d}"
<    end
---
>   def self.hello(*a)
>     puts "Hello #{a.join(',')}"
>   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 1345 remaining solutions by signing in and submitting your own entry
#1346 Patrick Muldoon / @d00n - Score: 206 - 12/29/10 @ 15:12
<Esc>:<Up><Up><Up><Up><Up>g.<BS>/.*def.$<BS>*end.*/d<CR>:v/\S/f<BS>d<CR>fai*<Esc><Right><Right>cf))<Esc><Down><Left>i.join(',')<Esc>lldf:df"a"<Esc>=<Esc><Esc><BS><Up><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left>xxxxxi  <Down><Down><Esc>x<Up><Right>xx<Esc>:wq<CR>

0 comments


Created by: @igrigorik

1346 active golfers, 5485 entries

Leaderboard (lowest score wins):
32
#151 - Vimgolf / @vimgolf987

02/27/2017 at 06:17AM

32
#152 - Andreas Anderbach / @anderbacha

03/20/2017 at 04:02PM

32
#153 - 20speedvegan / @ashkevinm

04/12/2017 at 05:10PM

32
#154 - sijinyuan / @sijinyuan

04/13/2017 at 03:36PM

32
#155 - 梧桐王子 / @WutongYujie

04/25/2017 at 03:53AM

32
#156 - Fausto NA / @brainlessdev

05/15/2017 at 12:18PM

32
#157 - Acid One / @AcidOne2

05/31/2017 at 10:48AM

32
#158 - Turkey Man / @lvturkeyman

11/08/2017 at 03:31PM

32
#159 - ParasamGateZero / @ParasamGateZero

01/22/2018 at 12:23AM

32
#160 - Andrew Peterson / @FungalRaincloud

07/30/2018 at 12:28AM

32
#161 - Coruja Queridinha / @miriamretka

08/24/2018 at 05:37PM

32
#162 - royer / @RoyerMoyer1

09/22/2018 at 02:07PM

32
#163 - ajs / @_ajsantander

10/14/2018 at 06:59PM

33
#164 - iCross / @iCrossOfficial

02/01/2011 at 04:52PM

33
#165 - Joost / @vlabakje

02/20/2011 at 01:17PM

33
#166 - Sergey Doroshenko / @dorserg

03/04/2011 at 07:48AM

33
#167 - Ruy Diaz / @diazruy

03/08/2011 at 06:20PM

33
#168 - Paweu1kZ nbNeyIhH / @yUQlwsFpRSzxJFh

03/09/2011 at 07:22AM

33
#169 - Aaron Jensen / @aaronjensen

03/18/2011 at 06:00AM

33
#170 - Mikael Gustavsson / @slvmnd

04/19/2011 at 02:53PM

33
#171 - こばばー / @symmet

04/24/2011 at 09:05AM

33
#172 - kjrn / @kjrnleto

05/20/2011 at 07:27PM

33
#173 - (Emile (Swarts)) / @EmileSwarts

05/29/2011 at 11:38AM

33
#174 - Justin Love / @wondible

06/03/2011 at 12:18PM

33
#175 - Black Wolf / @LoboVimGolf

06/15/2011 at 09:24AM

33
#176 - Rolf Bjaanes / @rolfb

06/15/2011 at 06:58PM

33
#177 - Jonathan / @saysjonathan

07/01/2011 at 01:21AM

33
#178 - Hu Junfeng / @junfeng

07/13/2011 at 11:52AM

33
#179 - Carlo Biedenharn / @Carlohedron

07/15/2011 at 09:46PM

33
#180 - ineb / @ineb0

08/14/2011 at 02:57PM