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 1357 remaining solutions by signing in and submitting your own entry
#1358 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

1358 active golfers, 5527 entries

Leaderboard (lowest score wins):
33
#211 - Marco Hinz / @_mhinz_

04/19/2013 at 06:17AM

33
#212 - iantalks / @iantalks

05/12/2013 at 02:04PM

33
#213 - rcmdnk / @rcmdnk

06/11/2013 at 10:13AM

33
#214 - Steve Tjoa / @stevetjoa

07/09/2013 at 06:07PM

33
#215 - Volodymyr / @vkrest

07/09/2013 at 06:32PM

33
#216 - Dom Armstrong / @dom_cycleface

08/19/2013 at 09:41PM

33
#217 - Super Garbage / @SuperGarbage0

08/29/2013 at 05:00AM

33
#218 - Dary Merckens / @merckens

09/23/2013 at 08:04PM

33
#219 - Dimitar Dimitrov / @kurkale6ka

10/17/2013 at 04:45PM

33
#220 - Casey Dwyer / @caseydwyer

10/23/2013 at 06:12AM

33
#221 - thasso / @thasso23

10/27/2013 at 01:28PM

33
#222 - James Scriven / @JamesDScriven

11/03/2013 at 09:33PM

33
#223 - Stefan Leszkiewicz / @stefanlz

11/17/2013 at 12:15AM

33
#224 - Павел Игоревич / @VizierST

02/02/2014 at 05:00PM

33
#225 - Jonathan Ellington / @JEllington90

02/02/2014 at 09:35PM

33
#226 - Zach Bennett / @saquintes

02/11/2014 at 03:35AM

33
#227 - radu petrutiu / @radu_petrutiu

02/15/2014 at 08:26PM

33
#228 - Konrad / @zichul

03/09/2014 at 01:50PM

33
#229 - RB / @powerage88

03/18/2014 at 10:55PM

33
#230 - Jacob / @jayekub

03/23/2014 at 02:43AM

33
#231 - Emil Soman / @emilsoman

06/05/2014 at 09:42PM

33
#232 - kwa / @kwa129

07/06/2014 at 12:18PM

33
#233 - April Gentle / @chen327684096

08/24/2014 at 10:42AM

33
#234 - Sergei Zhgirovski / @Ixanezis

10/11/2014 at 06:33PM

33
#235 - Garrett Smith / @garrettwhsmith

03/29/2015 at 05:17PM

33
#236 - E Both / @enboth

04/11/2015 at 07:54PM

33
#237 - LC / @leeren

08/22/2015 at 11:56PM

33
#238 - Walker Boh / @walker_boh

10/02/2015 at 09:30AM

33
#239 - Nam Net / @tafopigibi

10/24/2015 at 06:56PM

33
#240 - Peter / @sunirbmag

10/27/2015 at 07:39PM