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):
57
#1261 - Brian Shacklett / @bshacklett

12/29/2010 at 04:59AM

57
#1262 - Jordi Romero / @jordiromero

12/31/2010 at 04:11PM

57
#1263 - Andrei Dragomir / @adragomir

01/01/2011 at 09:37PM

57
#1264 - Stephen Gordon / @DubsGordon

08/02/2011 at 03:09AM

57
#1265 - sjatkinson / @sjatkinson

08/29/2011 at 02:48AM

57
#1266 - Mikhail Vaysman / @vaysman

06/26/2012 at 12:41AM

57
#1267 - nick kov / @nick_kov

12/17/2012 at 04:40AM

57
#1268 - Brad DeShong / @braddeshong

11/23/2013 at 01:54PM

57
#1269 - Eric Ahlberg / @e_ahlberg

12/10/2013 at 12:12PM

57
#1270 - Hendrik Lammers / @hendriklammers

05/17/2015 at 08:16AM

57
#1271 - Jurica / @Jurica34581259

11/15/2018 at 01:07AM

57
#1272 - Brian Donovan / @eventualbuddha

11/29/2018 at 02:23AM

57
#1273 - averageRandomPerson / @averageRandomP1

08/17/2019 at 01:43PM

58
#1274 - Charlie Liang Yuan / @_cly_

01/04/2011 at 09:39AM

58
#1275 - James Gary / @james_gary

06/22/2011 at 05:34PM

58
#1276 - Scott Myц / @ScottMuc

04/06/2013 at 05:18PM

58
#1277 - Eric Lau / @elau89

06/21/2014 at 10:11PM

58
#1278 - Brian Hall / @_bruab_

04/28/2017 at 01:12PM

58
#1279 - Benjamin Unger / @Ben_Unger

09/16/2017 at 01:41PM

59
#1280 - Wes Maldonado / @wes

12/28/2010 at 07:41PM

59
#1281 - travis spangle / @travisspangle

12/30/2010 at 09:49PM

59
#1282 - keo / @keo

03/04/2011 at 03:55PM

59
#1283 - Fred / @fredlee

05/27/2011 at 01:10PM

59
#1284 - John Ford / @GhettoCode

02/03/2012 at 09:56PM

59
#1285 - Paul Federspiel / @parobalth

11/10/2013 at 11:22PM

59
#1286 - TimWolla / @TimWolla

03/13/2014 at 10:27PM

59
#1287 - Luis Rodriguez / @luisthecoder

11/13/2018 at 03:37AM

60
#1288 - Unsouled / @unsouled0

12/30/2010 at 02:52AM

60
#1289 - Tomo.H / @joker1007

04/24/2011 at 08:01AM

60
#1290 - quintin / @quintinjeannoel

08/29/2011 at 07:35AM