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):
52
#1231 - alekfed / @alek_fed

04/15/2019 at 08:10AM

52
#1232 - Kai.Li / @KaiLi19

05/07/2019 at 05:46AM

53
#1233 - Cristi Balan / @evilchelu

12/28/2010 at 08:44PM

53
#1234 - Jonathan Perret / @jonathanperret

12/28/2010 at 09:07PM

53
#1235 - Zhao Yao / @Lynch8080

12/31/2010 at 07:01PM

53
#1236 - khebbie / @khebbie

06/16/2011 at 06:51PM

53
#1237 - Dave / @zzdave13

07/15/2011 at 10:49AM

53
#1238 - Scott Nielsen / @smniel

03/28/2012 at 08:11AM

53
#1239 - 蒼時弦也 / @elct9620

03/29/2012 at 11:00AM

53
#1240 - Corey Glynn / @albedoa

10/10/2012 at 02:14AM

53
#1241 - Paul Jay / @PaulJay91

03/15/2014 at 03:50AM

53
#1242 - Glauco Pires / @grpires

11/25/2014 at 01:07PM

53
#1243 - Izabel Jelenić / @IzabelJelenic

12/22/2015 at 08:51PM

53
#1244 - Austin Ware / @AustinWare17

03/12/2018 at 08:28PM

53
#1245 - jestem króliczkiem / @karlicoss

08/05/2018 at 02:50PM

53
#1246 - JulianW / @JulianWgs

11/03/2018 at 12:28PM

53
#1247 - Vim Golfer / @VimGolfer6

08/07/2019 at 01:02PM

54
#1248 - Nicolás Sanguinetti / @godfoca

12/28/2010 at 07:59PM

54
#1249 - conor / @omgconor

01/22/2011 at 12:07AM

54
#1250 - Levon Lloyd / @levonlloyd

02/04/2011 at 02:39PM

54
#1251 - Fletcher Nichol / @fnichol

03/21/2011 at 03:56AM

54
#1252 - Tof / @Tof23

06/17/2011 at 04:59AM

54
#1253 - cameron / @cameronaustgen

09/04/2011 at 08:50AM

54
#1254 - Rafael França / @rafaelfranca

09/27/2011 at 09:26PM

54
#1255 - kyriacos / @kyriacos

12/12/2011 at 04:15PM

54
#1256 - Casper Christensen / @Casper__C

12/04/2013 at 08:27PM

54
#1257 - Andrew Loucky / @merely_oolong

03/24/2014 at 11:21PM

54
#1258 - Samir Sadek / @netsamir

07/21/2015 at 05:52AM

54
#1259 - Conor Ryan / @conorjryan

11/18/2015 at 09:16AM

54
#1260 - Matt Walsh / @wattmalsh

02/06/2017 at 10:42PM