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

1399 active golfers, 5693 entries

Leaderboard (lowest score wins):
44
#931 - Masashi Iizuka / @uochan

04/03/2011 at 02:13AM

44
#932 - Mario Scheliga / @marioscheliga

05/14/2011 at 10:59PM

44
#933 - Justin Hale / @jxl

05/27/2011 at 08:27AM

44
#934 - Martin Lundberg / @marlun

05/30/2011 at 10:43AM

44
#935 - David Kormushoff / @Kormie

07/08/2011 at 04:46AM

44
#936 - Simon's Calf / @simonscarfe

08/30/2011 at 02:22PM

44
#937 - Sam Haskins / @samhaskins

09/16/2011 at 04:51PM

44
#938 - Alex Croteau-Pothier / @AlexCP_

12/10/2011 at 12:05AM

44
#939 - Craig Martek / @cregatron

01/26/2012 at 04:09PM

44
#940 - Tim Blair / @timblair

02/16/2012 at 10:27AM

44
#941 - lucapette / @lucapette

04/26/2012 at 10:04PM

44
#942 - Matt / @eastcoastbum

05/25/2012 at 05:43AM

44
#943 - Benjamin Sergeant / @bsergean

06/04/2012 at 04:05AM

44
#944 - Enrique García / @otikik

06/12/2012 at 10:10PM

44
#945 - metaphract / @metaphract

07/28/2012 at 07:34PM

44
#946 - ') DROP TABLE user; / @_ckafi

08/19/2012 at 01:34PM

44
#947 - Ravi S Sinha / @ambidextrousTx

08/29/2012 at 08:24AM

44
#948 - Vicente Sánchez / @froysm

09/09/2012 at 06:14AM

44
#949 - Domon / @Domon

09/11/2012 at 05:59AM

44
#950 - Brenno Costa / @brennovich

09/30/2012 at 10:51PM

44
#951 - Matt Burrows / @dic3m4n

12/19/2012 at 10:11AM

44
#952 - Charlene Tshos / @charlymul

04/09/2013 at 06:35PM

44
#953 - Balazs Nadasdi / @yitsushi

04/16/2013 at 06:46PM

44
#954 - ⚡ DRJ ⚡ / @midgetjones

06/08/2013 at 04:49PM

44
#955 - Dr. Rev. J. "Paranoid Android" Kirchartz / @JKirchartz

07/28/2013 at 08:15PM

44
#956 - cj / @cj01101

08/04/2013 at 02:09AM

44
#957 - Daniel Kovacic / @dkov01

09/02/2013 at 08:47PM

44
#958 - Brett Cassette / @brettcassette

12/01/2013 at 05:37AM

44
#959 - Devin V. / @enrual

12/15/2013 at 05:56AM

44
#960 - Pedro B. Coronel / @pbcoronel

01/28/2014 at 02:33AM