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):
34
#301 - Forrest Zeisler / @fzeisler

11/08/2013 at 02:07AM

34
#302 - Jacob Niehus / @wilywampa

12/18/2013 at 07:14AM

34
#303 - Bradford Powell / @dr_bpow

12/23/2013 at 08:45PM

34
#304 - Võ Duy Vinh / @VoDuyVinh

02/23/2014 at 01:38AM

34
#305 - Antonio Jesús / @antoniojesvs

02/27/2014 at 02:54PM

34
#306 - Jonas Arnold Clasen / @jonasclasen

06/08/2014 at 08:43PM

34
#307 - playalong / @playwithit42

07/08/2014 at 11:18AM

34
#308 - Tomasz Wesołowski / @KosGD

10/13/2014 at 07:47PM

34
#309 - Matt / @mcr05

12/05/2014 at 09:40PM

34
#310 - Josu Oyanguren / @josuoyanguren

12/22/2014 at 08:49AM

34
#311 - Skúli Jóhannsson / @skulibj

06/26/2015 at 02:15PM

34
#312 - retro / @tryphopp

01/10/2016 at 08:29AM

34
#313 - Thijs van den Anker / @thijsvdanker

02/15/2016 at 08:48AM

34
#314 - Bradley M. Small / @BradleySmall

11/20/2017 at 01:56PM

34
#315 - edvrds / @edvrds

04/20/2020 at 02:24PM

34
#316 - Topvimgolf Score / @topvimgolfscore

10/12/2022 at 10:58AM

34
#317 - Zion Park / @zionpark93

12/14/2022 at 11:19AM

34
#318 - Dogu / @DoguCSGO

02/25/2023 at 10:17PM

34
#319 - Mihael Protsko / @eastaveracruz

07/31/2023 at 04:00PM

34
#320 - 이원석 / @92lwsk

09/26/2023 at 07:36AM

34
#321 - tianxiaweiyidao / @tianxiaweiyidao

04/17/2024 at 04:27PM

34
#322 - sodawithbubbles / @sodawithbubbles

05/29/2024 at 10:06AM

34
#323 - imperatormatthias / @imperatormatthias

06/18/2024 at 03:59PM

34
#324 - Suhaib Murshid / @suhaibm

08/17/2024 at 07:44AM

34
#325 - Pablo Acuna / @pacuna

10/18/2024 at 01:23AM

34
#326 - 0xf00ff00f / @0xf00ff00f

12/29/2024 at 10:51PM

34
#327 - f0tze schlampe / @Nuttnsauger5000

02/20/2025 at 10:52PM

35
#328 - uuu / @uu59

12/30/2010 at 12:41AM

35
#329 - jacobangel / @jacobangel

12/31/2010 at 07:09AM

35
#330 - duckdalbe / @duckdalbe

01/14/2011 at 11:47AM