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

1369 active golfers, 5569 entries

Leaderboard (lowest score wins):
42
#841 - Ben Vandervalk / @benvvalk

09/14/2015 at 05:06AM

42
#842 - Gerald Tilma / @GeraldTilma

10/18/2015 at 04:11PM

42
#843 - Wilmer Bandres / @WilmerBandres

12/04/2015 at 12:44AM

42
#844 - Matteo Signer / @MatteoSigner

04/13/2016 at 06:53AM

42
#845 - Ian Malerich / @IMalerich

05/04/2016 at 10:30PM

42
#846 - Nigel Rahkola / @NinjaRahkola

05/13/2016 at 02:55AM

42
#847 - Abdullah / @dada3mn

08/11/2016 at 05:27AM

42
#848 - Codingpotato / @codingpotato

05/07/2017 at 09:55AM

42
#849 - Harsh Kumar / @datsleepyguy

06/24/2017 at 06:19PM

42
#850 - toddkoym / @toddkoym

08/08/2017 at 04:53AM

42
#851 - sehe / @sehetw

10/10/2017 at 02:39PM

42
#852 - P. Bogaard / @Pepbogaard

01/21/2018 at 10:33AM

42
#853 - Deepstack / @deepstackux

01/25/2019 at 05:30PM

42
#854 - Sherab Giovannini / @shaddycls

05/02/2019 at 11:14PM

42
#855 - Felipe Monteiro / @monteiro_fp

05/08/2019 at 10:16PM

42
#856 - fewfold / @fewfold

11/06/2019 at 01:43AM

43
#857 - Samuel Mullen / @samullen

12/28/2010 at 07:52PM

43
#858 - Dan Callahan / @callahad

12/28/2010 at 09:12PM

43
#859 - Gary Rennie / @TheGazler

08/03/2011 at 03:04PM

43
#860 - Shannon / @shannonskipper

11/29/2011 at 09:51AM

43
#861 - Michael Levin / @kinnetica

12/06/2011 at 05:19PM

43
#862 - Stephen Jennings / @sgjennings

02/02/2012 at 07:32AM

43
#863 - Manu / @bound_test

02/13/2012 at 09:16AM

43
#864 - Steven Sloss / @StevenSloss

02/16/2012 at 03:40PM

43
#865 - Peter Schlette / @pschlette

08/01/2012 at 04:40AM

43
#866 - Thiago Tasca Nunes / @ttascanunes

11/08/2012 at 05:54PM

43
#867 - Maksim S. / @waynesayonara

07/18/2013 at 07:17PM

43
#868 - Joel Taylor / @joelteon_

07/23/2013 at 02:09AM

43
#869 - Dan Harrington / @Dan1H1

08/13/2013 at 01:30AM

43
#870 - adi li / @guessimtoolate

08/14/2013 at 05:45PM