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

1399 active golfers, 5693 entries

Leaderboard (lowest score wins):
42
#871 - sehe / @sehetw

10/10/2017 at 02:39PM

42
#872 - P. Bogaard / @Pepbogaard

01/21/2018 at 10:33AM

42
#873 - Deepstack / @deepstackux

01/25/2019 at 05:30PM

42
#874 - Sherab Giovannini / @shaddycls

05/02/2019 at 11:14PM

42
#875 - Felipe Monteiro / @monteiro_fp

05/08/2019 at 10:16PM

42
#876 - fewfold / @fewfold

11/06/2019 at 01:43AM

43
#877 - Samuel Mullen / @samullen

12/28/2010 at 07:52PM

43
#878 - Dan Callahan / @callahad

12/28/2010 at 09:12PM

43
#879 - Gary Rennie / @TheGazler

08/03/2011 at 03:04PM

43
#880 - Shannon / @shannonskipper

11/29/2011 at 09:51AM

43
#881 - Michael Levin / @kinnetica

12/06/2011 at 05:19PM

43
#882 - Stephen Jennings / @sgjennings

02/02/2012 at 07:32AM

43
#883 - Manu / @bound_test

02/13/2012 at 09:16AM

43
#884 - Steven Sloss / @StevenSloss

02/16/2012 at 03:40PM

43
#885 - Peter Schlette / @pschlette

08/01/2012 at 04:40AM

43
#886 - Thiago Tasca Nunes / @ttascanunes

11/08/2012 at 05:54PM

43
#887 - Maksim S. / @waynesayonara

07/18/2013 at 07:17PM

43
#888 - Joel Taylor / @joelteon_

07/23/2013 at 02:09AM

43
#889 - Dan Harrington / @Dan1H1

08/13/2013 at 01:30AM

43
#890 - adi li / @guessimtoolate

08/14/2013 at 05:45PM

43
#891 - Kevin Etienne / @42__kevin

08/18/2013 at 06:45PM

43
#892 - Kostyantyn Leschenko / @settler_kos

08/19/2013 at 08:01AM

43
#893 - Tony Han / @tony612_han

08/31/2013 at 05:31AM

43
#894 - John Gray Cole / @johngraycole

12/08/2013 at 07:49PM

43
#895 - David M / @ohhhmandyyy

01/15/2014 at 11:35PM

43
#896 - Andreas Källberg / @Anka213

01/17/2014 at 12:06AM

43
#897 - Jonny / @Jonnytron

02/15/2014 at 05:20PM

43
#898 - wizardwerdna / @wizardwerdna

05/17/2014 at 08:46AM

43
#899 - Jake Eaton / @Jake__Eaton

06/01/2014 at 05:53AM

43
#900 - blamitter ✏️ / @blamitter

07/01/2014 at 09:21PM