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):
48
#1111 - lilach adir / @leelaRed

04/03/2016 at 12:33PM

48
#1112 - Dan Madden / @guthran

07/15/2016 at 04:24PM

48
#1113 - Yann / @yannstad

02/20/2017 at 01:20AM

48
#1114 - Anders Schramm / @AndersSchramm

05/23/2017 at 11:21AM

48
#1115 - Joel Meyer-Hamme / @JoelMeyerHamme

06/21/2017 at 01:48PM

48
#1116 - Stop and think / @ms_uncountable

07/06/2017 at 07:11AM

48
#1117 - eL Bunda / @elbund4

06/23/2018 at 07:18PM

48
#1118 - Commi / @hellocommi

11/25/2018 at 11:38PM

48
#1119 - Luiz Eduardo Amaral / @_luxedo

08/09/2019 at 05:09PM

49
#1120 - Tim Dean / @Tmdean

12/29/2010 at 10:06PM

49
#1121 - Kasper Bjørn Nielsen / @kasperbn

01/01/2011 at 05:28PM

49
#1122 - sedohr nimajneb / @nerdyworms

01/24/2011 at 06:59PM

49
#1123 - Beau Dacious / @nocash

03/16/2011 at 04:16PM

49
#1124 - Zach Belzer / @zbelzer

03/17/2011 at 07:52PM

49
#1125 - t__naka / @t__naka

08/07/2011 at 09:30AM

49
#1126 - Carl Leiby / @carlism

10/20/2011 at 01:54PM

49
#1127 - Vivus Ignis / @vivus_ignis

12/22/2011 at 06:11PM

49
#1128 - Jason Punyon / @JasonPunyon

06/20/2012 at 02:27AM

49
#1129 - annagrammatica1 / @annagrammatica1

08/02/2012 at 05:01AM

49
#1130 - Tom Cammann / @tea_sea

10/08/2012 at 12:03PM

49
#1131 - Drew Chandler / @drklutch

10/08/2012 at 11:07PM

49
#1132 - Heath Ritchie / @heathritchie

11/13/2012 at 07:53PM

49
#1133 - Niclas Thall / @thallniclas

04/22/2013 at 06:22PM

49
#1134 - Richard John Soni / @richsoni

06/07/2013 at 05:59PM

49
#1135 - George GZ Zakhour / @AlloGeorge

06/25/2013 at 08:01AM

49
#1136 - Felipe Jaramillo F / @mrfelipe

04/01/2014 at 06:25PM

49
#1137 - Hieu M. Nguyen / @ngnmhieu

08/15/2014 at 11:35PM

49
#1138 - Malte R / @maltoe

11/30/2014 at 02:47PM

49
#1139 - Jordana Lachow / @TomofBedlam

01/06/2015 at 04:10PM

49
#1140 - ipson_nek / @ipson_nek

04/03/2015 at 06:36PM