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

1398 active golfers, 5692 entries

Leaderboard (lowest score wins):
48
#1141 - eL Bunda / @elbund4

06/23/2018 at 07:18PM

48
#1142 - Commi / @hellocommi

11/25/2018 at 11:38PM

48
#1143 - Luiz Eduardo Amaral / @_luxedo

08/09/2019 at 05:09PM

49
#1144 - Tim Dean / @Tmdean

12/29/2010 at 10:06PM

49
#1145 - Kasper Bjørn Nielsen / @kasperbn

01/01/2011 at 05:28PM

49
#1146 - sedohr nimajneb / @nerdyworms

01/24/2011 at 06:59PM

49
#1147 - Beau Dacious / @nocash

03/16/2011 at 04:16PM

49
#1148 - Zach Belzer / @zbelzer

03/17/2011 at 07:52PM

49
#1149 - t__naka / @t__naka

08/07/2011 at 09:30AM

49
#1150 - Carl Leiby / @carlism

10/20/2011 at 01:54PM

49
#1151 - Vivus Ignis / @vivus_ignis

12/22/2011 at 06:11PM

49
#1152 - Jason Punyon / @JasonPunyon

06/20/2012 at 02:27AM

49
#1153 - annagrammatica1 / @annagrammatica1

08/02/2012 at 05:01AM

49
#1154 - Tom Cammann / @tea_sea

10/08/2012 at 12:03PM

49
#1155 - Drew Chandler / @drklutch

10/08/2012 at 11:07PM

49
#1156 - Heath Ritchie / @heathritchie

11/13/2012 at 07:53PM

49
#1157 - Niclas Thall / @thallniclas

04/22/2013 at 06:22PM

49
#1158 - Richard John Soni / @richsoni

06/07/2013 at 05:59PM

49
#1159 - George GZ Zakhour / @AlloGeorge

06/25/2013 at 08:01AM

49
#1160 - Felipe Jaramillo F / @mrfelipe

04/01/2014 at 06:25PM

49
#1161 - Hieu M. Nguyen / @ngnmhieu

08/15/2014 at 11:35PM

49
#1162 - Malte R / @maltoe

11/30/2014 at 02:47PM

49
#1163 - Jordana Lachow / @TomofBedlam

01/06/2015 at 04:10PM

49
#1164 - ipson_nek / @ipson_nek

04/03/2015 at 06:36PM

49
#1165 - Kirill Sidenko / @KirillSidenko

06/19/2016 at 12:13PM

49
#1166 - Charlie OConor / @charlieoconor

10/30/2017 at 04:53PM

49
#1167 - faisal / @faisalhackshah

11/25/2018 at 03:28AM

50
#1168 - Jordan Lewis / @JordanALewis

12/30/2010 at 06:47PM

50
#1169 - Oleg Pestov / @opestov

03/14/2011 at 06:19PM

50
#1170 - Unreal Name / @morphles

06/02/2011 at 11:06AM