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

1374 active golfers, 5587 entries

Leaderboard (lowest score wins):
44
#931 - Domon / @Domon

09/11/2012 at 05:59AM

44
#932 - Brenno Costa / @brennovich

09/30/2012 at 10:51PM

44
#933 - Matt Burrows / @dic3m4n

12/19/2012 at 10:11AM

44
#934 - Charlene Tshos / @charlymul

04/09/2013 at 06:35PM

44
#935 - Balazs Nadasdi / @yitsushi

04/16/2013 at 06:46PM

44
#936 - ⚡ DRJ ⚡ / @midgetjones

06/08/2013 at 04:49PM

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

07/28/2013 at 08:15PM

44
#938 - cj / @cj01101

08/04/2013 at 02:09AM

44
#939 - Daniel Kovacic / @dkov01

09/02/2013 at 08:47PM

44
#940 - Brett Cassette / @brettcassette

12/01/2013 at 05:37AM

44
#941 - Devin V. / @enrual

12/15/2013 at 05:56AM

44
#942 - Pedro B. Coronel / @pbcoronel

01/28/2014 at 02:33AM

44
#943 - Chris Ciulla / @chris_ciulla

01/30/2014 at 01:48AM

44
#944 - Jae Won Kim / @jaewone

02/03/2014 at 07:29AM

44
#945 - Huang Yu / @trave7er

03/05/2014 at 05:24PM

44
#946 - Solar Powered Robot / @moskrin

05/01/2014 at 06:35PM

44
#947 - Harald H / @metellius

08/20/2014 at 10:21AM

44
#948 - Daniel Burnett / @mango_cheetah

10/10/2014 at 04:51PM

44
#949 - Aaron Whittington / @whittaaron

01/16/2015 at 03:09AM

44
#950 - Mark Saiget / @MarkSaiget

04/22/2015 at 03:34AM

44
#951 - Carsten Lenz / @carstenlenz

05/03/2015 at 06:12PM

44
#952 - Brian Besmanoff / @BrianBesmanoff

08/06/2015 at 05:34AM

44
#953 - Alex Bartol / @alexbartol

09/15/2015 at 06:05PM

44
#954 - Thomas Williams / @neopsalmist

01/06/2016 at 02:47PM

44
#955 - Clémence / @Clemence_Neoxia

05/23/2016 at 07:31AM

44
#956 - Will / @obiwan__k3n00bi

08/14/2016 at 10:47PM

44
#957 - Mark Brody / @_markbrody

03/23/2017 at 05:37AM

44
#958 - Geoff / @RealGeoffErwin

09/29/2017 at 06:52PM

44
#959 - たぬぽん / @eJYwMbymauWKF4B

06/11/2019 at 12:23PM

44
#960 - David Barker / @dashleybarker

12/31/2019 at 04:54PM