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

1486 active golfers, 6033 entries

Leaderboard (lowest score wins):
41
#841 - Kris Ezra / @kris_ezra

09/12/2018 at 03:39AM

41
#842 - Dryvnt / @Dryvnt

04/04/2019 at 01:20PM

41
#843 - Simon Zeng / @KronicMan

06/15/2019 at 05:01PM

41
#844 - Iggy / @iggredible

10/24/2019 at 02:51AM

41
#845 - Lory / @Lory46845742

11/08/2019 at 08:36AM

41
#846 - Matt Aschmann / @ma7hatter

12/30/2019 at 06:44PM

41
#847 - Karnival K / @K4rnival

01/15/2020 at 07:16PM

41
#848 - Jason Neylon / @jasonneylon

01/18/2020 at 01:43PM

41
#849 - Jason / @roosjason

04/25/2020 at 11:08AM

41
#850 - Jeff Cui / @jeffacce

05/13/2020 at 10:35AM

41
#851 - Pham Tuan Anh / @anhpt379

06/28/2020 at 09:12PM

41
#852 - pherapont / @pherapont1

12/21/2020 at 07:59AM

41
#853 - josh / @_zvjos

06/17/2022 at 01:28AM

41
#854 - (ノ◕ヮ◕)ノ*:・゚✧ / @Mebazaa

07/01/2022 at 04:28PM

42
#855 - Dmytro Shteflyuk / @kpumuk

12/29/2010 at 03:57PM

42
#856 - Jarkko Laine / @jarkko

12/29/2010 at 07:18PM

42
#857 - emmanuel delgado / @chischaschos

01/03/2011 at 12:37AM

42
#858 - Ben Bleything / @bleything

01/05/2011 at 08:57PM

42
#859 - Michael Yasumoto / @yasumotouw

01/11/2011 at 08:28PM

42
#860 - Kai Wood / @kwd_io

04/04/2011 at 11:07AM

42
#861 - Craig H. Anderson / @CootCraig

04/17/2011 at 08:05AM

42
#862 - Hervo Manuel / @Azema31

05/18/2011 at 06:43PM

42
#863 - Pete Brown / @beerlington

06/03/2011 at 03:44AM

42
#864 - marssong / @marssong

10/10/2011 at 11:23AM

42
#865 - Nathan Ehresman / @nehresman

11/16/2011 at 07:54PM

42
#866 - Sergii Galashyn / @sgalashyn

12/21/2011 at 11:47AM

42
#867 - suhair hassan / @suhairhassan

12/27/2011 at 11:16AM

42
#868 - GiaNU / @sgianazza

01/31/2012 at 03:30PM

42
#869 - matthew / @mdespuits

02/03/2012 at 06:51AM

42
#870 - Shane Emmons / @semmons99

02/10/2012 at 12:31PM