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

1321 active golfers, 5391 entries

Leaderboard (lowest score wins):
35
#331 - Yongho / @YONG_HO

02/06/2014 at 10:17AM

35
#332 - Joonas Pihlajamaa / @jokkebk

02/08/2014 at 11:26PM

35
#333 - Hannes Remahl / @hannesr

02/27/2014 at 04:17PM

35
#334 - William Snyders / @iam2391212

03/05/2014 at 12:10AM

35
#335 - Norm Fasey / @DeathRay1977

05/02/2014 at 09:13PM

35
#336 - Mauro Persano / @fzort

11/16/2014 at 10:19AM

35
#337 - Test User / @TestUserIgnore

12/04/2014 at 11:22PM

35
#338 - David Han / @HanDavid

12/07/2014 at 04:03AM

35
#339 - Sntano Euhsk / @SEuhsk

01/15/2015 at 11:21PM

35
#340 - TheProgrammer971 / @tp971

03/14/2015 at 02:22AM

35
#341 - Faat / @i_faat

01/29/2016 at 01:45PM

35
#342 - James Burns / @James_Ian_Burns

02/21/2016 at 02:54PM

35
#343 - Yahyalexandre33 / @yahyalexandre33

03/15/2016 at 07:57AM

35
#344 - S O / @strangelooperer

04/17/2016 at 09:04PM

35
#345 - Håkon Bråten / @h_braten

04/26/2016 at 03:52PM

35
#346 - Andres Araya / @arayaandresfco

05/15/2016 at 07:41PM

35
#347 - (,,꒪꒫꒪,,) / @sneer

05/22/2016 at 07:38AM

35
#348 - Jan Bundesmann / @janbundesmann

05/31/2016 at 12:44PM

35
#349 - Reuben Huxley / @missiontocode

06/29/2016 at 09:51PM

35
#350 - TweetDreams / @TweetMusicians

10/08/2016 at 10:16PM

35
#351 - Benoit Mortgat / @Benoit_Mortgat

11/14/2017 at 10:49AM

35
#352 - Eric Liao / @rcliaodev

12/07/2017 at 07:30AM

35
#353 - herbage / @herbage2

01/03/2018 at 09:04PM

35
#354 - Guirec CORBEL / @GuirecCorbel

03/07/2018 at 11:09AM

35
#355 - Daniël De Koker / @daniel_koker

07/01/2018 at 12:51PM

35
#356 - Benjamin Kiesl / @BenjaminKiesl

10/17/2018 at 12:01PM

36
#357 - Kerry Buckley / @kerryb

12/29/2010 at 07:55AM

36
#358 - kana / @kana1

12/29/2010 at 04:30PM

36
#359 - Akira Matsuda / @a_matsuda

12/30/2010 at 02:05AM

36
#360 - Scott Abernethy / @scott_abernethy

12/31/2010 at 03:41AM