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):
47
#1081 - Gitsnik / @dracyrys

04/22/2019 at 12:33PM

48
#1082 - Jon Bettinger / @jonbettinger

12/29/2010 at 02:55AM

48
#1083 - Hunter Haugen / @Hunnur

12/31/2010 at 01:09AM

48
#1084 - d6rkaiz / @d6rkaiz

12/31/2010 at 08:53AM

48
#1085 - Rohith Ravi / @entombedvirus

12/31/2010 at 10:38PM

48
#1086 - Jeroen / @teranex

03/02/2011 at 10:25PM

48
#1087 - Thom Hughes / @thom_hughes_1

04/06/2011 at 12:56PM

48
#1088 - xeal / @xeal

08/23/2011 at 06:33AM

48
#1089 - Mike Skalnik / @skalnik

10/01/2011 at 12:29PM

48
#1090 - Arlekin de Palermo / @arlekinpalermo

10/15/2011 at 04:35PM

48
#1091 - Daniel Harrington / @rubiii

12/10/2011 at 07:31PM

48
#1092 - Nikolai Kristiansen / @nikolaik

01/02/2012 at 09:52PM

48
#1093 - Tuxz / @Tuxz

01/30/2012 at 12:25PM

48
#1094 - Scott Mathson / @smathson

02/04/2012 at 01:16AM

48
#1095 - Jonathan C. Dietrich / @jcdietrich

02/08/2012 at 01:45PM

48
#1096 - Vimgolf stinks / @Vimgolfstinks

04/11/2012 at 07:45PM

48
#1097 - Dimitri De Frenne / @ddefrenne

04/21/2012 at 12:11PM

48
#1098 - Chris Ginter / @ginterUF

06/20/2012 at 07:27PM

48
#1099 - pu / @pawwwelek1989

09/11/2012 at 02:03AM

48
#1100 - Algor / @algor_1

10/06/2012 at 12:18PM

48
#1101 - うえっち / @uh_tomo

12/04/2012 at 03:53PM

48
#1102 - Andrew Dennis / @ALzonedOut

07/18/2013 at 12:01AM

48
#1103 - No Thank You / @raehik

08/20/2013 at 12:08PM

48
#1104 - Fontaine Kévin / @DotSlash974

08/24/2013 at 11:25AM

48
#1105 - Lev Walkin / @levwalkin

10/27/2013 at 08:40AM

48
#1106 - Mick Garvey / @blarko

04/01/2014 at 12:08AM

48
#1107 - Rafee / @rafee_buet

07/19/2014 at 06:51PM

48
#1108 - Brad Garland / @bradg

09/24/2014 at 02:46AM

48
#1109 - Andrew Michaud / @andrewjmichaud

09/04/2015 at 12:53AM

48
#1110 - Kyle Nesslein / @knessl

10/02/2015 at 04:50PM