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

1754 active golfers, 7154 entries

Leaderboard (lowest score wins):
33
#271 - Michael / @openemitter

12/26/2023 at 09:37PM

33
#272 - nmiller987 / @nmiller987

09/20/2024 at 03:39PM

33
#273 - kevincking1986 / @kevincking1986

03/24/2025 at 01:29PM

34
#274 - Ricardo Mendes / @locks

12/30/2010 at 03:45PM

34
#275 - Richard Sanchez / @vimlearner

01/01/2011 at 05:26AM

34
#276 - Jonathan / @jdelStrother

01/02/2011 at 07:16PM

34
#277 - derp derp / @derp__

01/05/2011 at 06:55AM

34
#278 - Balkoth / @_Balkoth_

01/08/2011 at 04:41PM

34
#279 - Ben Griffiths / @beng

01/11/2011 at 04:49PM

34
#280 - Andrey Ivanov / @Bytamine

01/19/2011 at 09:20PM

34
#281 - Oleg Roshupkin / @jjjahson

01/20/2011 at 04:01PM

34
#282 - Andrey A. Ugolnik / @andreyugolnik

01/22/2011 at 02:30AM

34
#283 - BigBlackBear / @BigBlackBear

01/26/2011 at 08:57PM

34
#284 - Rainer Testa / @Rainersglueck

02/15/2011 at 10:19PM

34
#285 - Sam Washington / @shabalay

08/18/2011 at 03:59PM

34
#286 - abelourenco / @abelourenco

12/06/2011 at 08:43PM

34
#287 - A / @tndrnt

12/10/2011 at 11:10AM

34
#288 - Mikael Amborn / @mikaelamborn

01/30/2012 at 08:48PM

34
#289 - Dave Harrington / @ozzy_dave

02/17/2012 at 11:14PM

34
#290 - Nicholas Amina / @apolatg

09/25/2012 at 06:28PM

34
#291 - Pavel Ryumin / @alcworx

09/29/2012 at 02:33PM

34
#292 - Gerhard Burger / @GaGerhard

10/31/2012 at 01:18PM

34
#293 - BZ_VG / @BZ_VG

11/12/2012 at 09:47AM

34
#294 - Adelar S. Queiróz / @adelarsq

11/28/2012 at 01:03AM

34
#295 - Jonas Engman / @jodas

02/18/2013 at 02:43PM

34
#296 - Ben / @bdchauvette

05/03/2013 at 07:48AM

34
#297 - Booberius / @booberius

05/29/2013 at 04:31PM

34
#298 - Christopher Bahr / @bahrware

07/11/2013 at 04:59AM

34
#299 - Elias Dorneles / @eliasdorneles

09/03/2013 at 04:46AM

34
#300 - Matt Green / @emgeeeeee

09/15/2013 at 03:44AM