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
#241 - radu petrutiu / @radu_petrutiu

02/15/2014 at 08:26PM

33
#242 - Konrad / @zichul

03/09/2014 at 01:50PM

33
#243 - RB / @powerage88

03/18/2014 at 10:55PM

33
#244 - Jacob / @jayekub

03/23/2014 at 02:43AM

33
#245 - Emil Soman / @emilsoman

06/05/2014 at 09:42PM

33
#246 - kwa / @kwa129

07/06/2014 at 12:18PM

33
#247 - April Gentle / @chen327684096

08/24/2014 at 10:42AM

33
#248 - Sergei Zhgirovski / @Ixanezis

10/11/2014 at 06:33PM

33
#249 - Garrett Smith / @garrettwhsmith

03/29/2015 at 05:17PM

33
#250 - E Both / @enboth

04/11/2015 at 07:54PM

33
#251 - LC / @leeren

08/22/2015 at 11:56PM

33
#252 - Walker Boh / @walker_boh

10/02/2015 at 09:30AM

33
#253 - Nam Net / @tafopigibi

10/24/2015 at 06:56PM

33
#254 - Peter / @sunirbmag

10/27/2015 at 07:39PM

33
#255 - John Smith / @literacyisgood

02/02/2016 at 10:45PM

33
#256 - ben kavanagh / @bkava

02/22/2016 at 04:11AM

33
#257 - Robber Toe / @robbertoe

04/03/2016 at 02:22AM

33
#258 - Vaughn Cato / @vaughncato

04/23/2016 at 02:33PM

33
#259 - John Goes / @johnwgoes

05/04/2016 at 03:21PM

33
#260 - vic © / @2r2w

05/23/2016 at 03:20PM

33
#261 - Gabriel Tailor / @gabriel_tailor

06/21/2016 at 03:41AM

33
#262 - Ram Tamtam / @ramtamtamtam

06/22/2016 at 02:08PM

33
#263 - Alexander Bessonov / @nonsleepr

03/13/2017 at 10:31PM

33
#264 - Solomon / @Trugbildjaeger

03/30/2017 at 08:13PM

33
#265 - Remus Dalrymple / @bornintheflames

05/06/2017 at 10:23AM

33
#266 - Дима / @dimkino

09/07/2017 at 06:33PM

33
#267 - 于吉星 / @fishermryn

05/27/2020 at 08:27AM

33
#268 - Romain / @djizeuscoco

07/01/2020 at 10:24AM

33
#269 - Michel Viktor / @tomkpz

08/09/2021 at 06:03PM

33
#270 - FeAx / @_FeAx_

06/21/2023 at 09:23PM