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):
43
#1081 - Delusi Van Houtan / @VanDelusi

03/02/2023 at 08:34AM

43
#1082 - James Reading / @bowly_jim

04/18/2023 at 08:13PM

43
#1083 - Charlie / @Ciscodefran

02/08/2024 at 11:36PM

43
#1084 - Sergey Artushkevich / @artcha

04/25/2024 at 05:01AM

43
#1085 - teorica / @teorica

05/18/2024 at 03:22AM

43
#1086 - Joshua Hamlet / @joshuahamlet

07/09/2024 at 06:58AM

43
#1087 - Judah / @jsczek

07/09/2024 at 01:49PM

43
#1088 - David Cavaceci / @dcavacec

08/18/2024 at 10:43PM

43
#1089 - akovaski / @akovaski

08/28/2024 at 04:31AM

43
#1090 - Gerrit Wanderer / @GerritWanderer

09/17/2024 at 09:17AM

43
#1091 - Gooplet / @goopletdev

04/15/2025 at 09:32PM

44
#1092 - 東 / @lldong

12/29/2010 at 08:08AM

44
#1093 - kkaefer / @kkaefer

12/29/2010 at 11:11AM

44
#1094 - Anders H. Madsen / @andershellerup

01/03/2011 at 07:27PM

44
#1095 - yc_p / @yc_p

01/04/2011 at 08:37PM

44
#1096 - Stephen Brandwood / @sbrandwoo

01/08/2011 at 06:19PM

44
#1097 - Alekseyka2 / @Alekseyka2

01/25/2011 at 02:24PM

44
#1098 - Steve Newell / @newellista

03/18/2011 at 03:04PM

44
#1099 - Masashi Iizuka / @uochan

04/03/2011 at 02:13AM

44
#1100 - Mario Scheliga / @marioscheliga

05/14/2011 at 10:59PM

44
#1101 - Justin Hale / @jxl

05/27/2011 at 08:27AM

44
#1102 - Martin Lundberg / @marlun

05/30/2011 at 10:43AM

44
#1103 - David Kormushoff / @Kormie

07/08/2011 at 04:46AM

44
#1104 - Simon Scarfe / @simonscarfe

08/30/2011 at 02:22PM

44
#1105 - Sam Haskins / @samhaskins

09/16/2011 at 04:51PM

44
#1106 - Alex Croteau-Pothier / @AlexCP_

12/10/2011 at 12:05AM

44
#1107 - Craig Martek / @cregatron

01/26/2012 at 04:09PM

44
#1108 - Tim Blair / @timblair

02/16/2012 at 10:27AM

44
#1109 - lucapette / @lucapette

04/26/2012 at 10:04PM

44
#1110 - Matt / @eastcoastbum

05/25/2012 at 05:43AM