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

1791 active golfers, 7259 entries

Leaderboard (lowest score wins):
42
#991 - Lucius L. Hilley III / @unkmar

02/27/2014 at 10:26AM

42
#992 - Fat troll / @fat_troll

03/29/2014 at 07:55AM

42
#993 - Shefaet / @shefaet

05/13/2014 at 11:54PM

42
#994 - Naoki Masuko / @nmasuko

07/11/2014 at 10:41PM

42
#995 - fa / @twiteciop

08/06/2014 at 07:43PM

42
#996 - Ene / @enesick

08/08/2014 at 11:47AM

42
#997 - Weijun He / @hewjun

08/31/2014 at 03:04PM

42
#998 - Giovanni Garufi / @garufi_giovanni

09/13/2014 at 10:56PM

42
#999 - Jose Gutierrez / @Jogusa

09/20/2014 at 11:25AM

42
#1000 - Oliver Christ / @0liverChrist

01/12/2015 at 10:29PM

42
#1001 - SilentFl / @Silent_Fl

01/27/2015 at 08:16AM

42
#1002 - Ben Vandervalk / @benvvalk

09/14/2015 at 05:06AM

42
#1003 - Gerald Tilma / @GeraldTilma

10/18/2015 at 04:11PM

42
#1004 - Wilmer Bandres / @WilmerBandres

12/04/2015 at 12:44AM

42
#1005 - Matteo Signer / @MatteoSigner

04/13/2016 at 06:53AM

42
#1006 - Ian Malerich / @IMalerich

05/04/2016 at 10:30PM

42
#1007 - Nigel Rahkola / @NinjaRahkola

05/13/2016 at 02:55AM

42
#1008 - Abdullah / @dada3mn

08/11/2016 at 05:27AM

42
#1009 - Codingpotato / @codingpotato

05/07/2017 at 09:55AM

42
#1010 - Harsh Kumar / @datsleepyguy

06/24/2017 at 06:19PM

42
#1011 - toddkoym / @toddkoym

08/08/2017 at 04:53AM

42
#1012 - sehe / @sehetw

10/10/2017 at 02:39PM

42
#1013 - P. Bogaard / @Pepbogaard

01/21/2018 at 10:33AM

42
#1014 - Deepstack / @deepstackux

01/25/2019 at 05:30PM

42
#1015 - Sherab Giovannini / @shaddycls

05/02/2019 at 11:14PM

42
#1016 - Felipe Monteiro / @monteiro_fp

05/08/2019 at 10:16PM

42
#1017 - fewfold / @fewfold

11/06/2019 at 01:43AM

42
#1018 - Martin Kauppinen / @MartinKauppinen

08/16/2020 at 02:11PM

42
#1019 - Brendan Schaenzer / @bschaenzer

09/30/2020 at 07:20PM

42
#1020 - x03n046 / @x03n046

05/11/2022 at 08:45AM