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

1791 active golfers, 7259 entries

Leaderboard (lowest score wins):
47
#1261 - Hannibal7878 / @Hannibal7878

02/15/2011 at 11:47PM

47
#1262 - Jack Kinsella / @jackkinsella

07/10/2011 at 07:04PM

47
#1263 - William Hua / @attente

07/17/2011 at 12:06PM

47
#1264 - Gar Morley / @garmorley

12/17/2011 at 05:38PM

47
#1265 - rajesh parvathaneni / @rparvathaneni

01/10/2012 at 12:05AM

47
#1266 - Alexander Soborov / @excelenter

01/16/2012 at 04:29PM

47
#1267 - João Veiga / @jcsvveiga

02/12/2012 at 11:52AM

47
#1268 - Jeremy Voorhis / @jvoorhis

02/14/2012 at 11:30PM

47
#1269 - ise0615 / @ise0615

05/04/2012 at 04:12PM

47
#1270 - Patrik Björklund / @pbjorklund

06/15/2012 at 02:42PM

47
#1271 - Richard / @crazyyoss

08/29/2012 at 11:57PM

47
#1272 - Stephen / @StephenPek

10/04/2012 at 03:15AM

47
#1273 - Kirill / @wedens_

11/19/2012 at 09:00AM

47
#1274 - Matthew Paul / @gilbrilthor

12/17/2012 at 04:41PM

47
#1275 - welbjo / @welbjo

01/23/2013 at 10:41PM

47
#1276 - Pieter Kuijpers / @pkuijpers

03/07/2013 at 09:42PM

47
#1277 - scturtle / @scturtle

04/12/2013 at 07:43AM

47
#1278 - Nick Rowe / @nixterrimus

05/15/2013 at 10:28PM

47
#1279 - Fl4t / @Fl4t

05/28/2013 at 09:34PM

47
#1280 - William / @wlmeng11

07/28/2013 at 05:33AM

47
#1281 - Hachez Floran / @FloranHachez

09/02/2013 at 05:05PM

47
#1282 - Anatolii Sakhnik / @sakhnik

09/30/2013 at 02:19PM

47
#1283 - Monroe Walker / @monroewlkr

10/16/2013 at 06:21AM

47
#1284 - Zachery Chin / @momochi0

11/05/2013 at 04:44AM

47
#1285 - mwcz / @mwcz

11/05/2013 at 08:05PM

47
#1286 - wilddog64 / @chengkai318

12/17/2013 at 03:51PM

47
#1287 - William Fligor / @williamfligor

01/28/2014 at 07:29PM

47
#1288 - Ronny Esterluss / @esterlus

01/29/2014 at 02:48PM

47
#1289 - João Paiva / @jgpaiva

01/29/2014 at 05:14PM

47
#1290 - Aidan Brumsickle / @aidanbrumsickle

03/26/2014 at 05:58PM