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):
52
#1201 - Pierre Maoui / @poupougnac

12/17/2016 at 04:20PM

52
#1202 - Ilya Shakirov / @aelaau

03/20/2017 at 09:35AM

52
#1203 - Jenny Johnson / @Kippz07

05/12/2017 at 03:16PM

52
#1204 - Adam Matan / @adam_matan

07/31/2017 at 10:26PM

52
#1205 - alekfed / @alek_fed

04/15/2019 at 08:10AM

52
#1206 - Kai.Li / @KaiLi19

05/07/2019 at 05:46AM

53
#1207 - Cristi Balan / @evilchelu

12/28/2010 at 08:44PM

53
#1208 - Jonathan Perret / @jonathanperret

12/28/2010 at 09:07PM

53
#1209 - Zhao Yao / @Lynch8080

12/31/2010 at 07:01PM

53
#1210 - khebbie / @khebbie

06/16/2011 at 06:51PM

53
#1211 - Dave / @zzdave13

07/15/2011 at 10:49AM

53
#1212 - Scott Nielsen / @smniel

03/28/2012 at 08:11AM

53
#1213 - 蒼時弦也 / @elct9620

03/29/2012 at 11:00AM

53
#1214 - Corey Glynn / @albedoa

10/10/2012 at 02:14AM

53
#1215 - Paul Jay / @PaulJay91

03/15/2014 at 03:50AM

53
#1216 - Glauco Pires / @grpires

11/25/2014 at 01:07PM

53
#1217 - Izabel Jelenić / @IzabelJelenic

12/22/2015 at 08:51PM

53
#1218 - Austin Ware / @AustinWare17

03/12/2018 at 08:28PM

53
#1219 - jestem króliczkiem / @karlicoss

08/05/2018 at 02:50PM

53
#1220 - JulianW / @JulianWgs

11/03/2018 at 12:28PM

53
#1221 - Vim Golfer / @VimGolfer6

08/07/2019 at 01:02PM

54
#1222 - Nicolás Sanguinetti / @godfoca

12/28/2010 at 07:59PM

54
#1223 - conor / @omgconor

01/22/2011 at 12:07AM

54
#1224 - Levon Lloyd / @levonlloyd

02/04/2011 at 02:39PM

54
#1225 - Fletcher Nichol / @fnichol

03/21/2011 at 03:56AM

54
#1226 - Tof / @Tof23

06/17/2011 at 04:59AM

54
#1227 - cameron / @cameronaustgen

09/04/2011 at 08:50AM

54
#1228 - Rafael França / @rafaelfranca

09/27/2011 at 09:26PM

54
#1229 - kyriacos / @kyriacos

12/12/2011 at 04:15PM

54
#1230 - Casper Christensen / @Casper__C

12/04/2013 at 08:27PM