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):
44
#1141 - Clémence / @Clemence_Neoxia

05/23/2016 at 07:31AM

44
#1142 - Will / @obiwan__k3n00bi

08/14/2016 at 10:47PM

44
#1143 - Mark Brody / @_markbrody

03/23/2017 at 05:37AM

44
#1144 - Geoff / @RealGeoffErwin

09/29/2017 at 06:52PM

44
#1145 - たぬぽん / @eJYwMbymauWKF4B

06/11/2019 at 12:23PM

44
#1146 - David Barker / @dashleybarker

12/31/2019 at 04:54PM

44
#1147 - countime / @countime1

03/11/2020 at 12:32AM

44
#1148 - 정현우 / @butijung

01/17/2022 at 01:23PM

44
#1149 - anonymouse / @anonymo65837183

03/10/2022 at 07:11AM

44
#1150 - Apkrattare / @propanesupplies

05/17/2022 at 09:04AM

44
#1151 - mika / @mika31120321

08/27/2022 at 05:36PM

44
#1152 - Zayn Yuan / @YuanDao1314

10/21/2022 at 01:02AM

44
#1153 - robit ultra lark / @RobitUltra

04/16/2023 at 12:01AM

44
#1154 - amberg12 / @amberg12

08/06/2024 at 08:52PM

44
#1155 - jaunxter / @jaunxter

04/04/2025 at 06:02AM

44
#1156 - kagidab / @kagidab

05/23/2025 at 02:33AM

44
#1157 - mf06359 / @mf06359

07/10/2025 at 02:25AM

45
#1158 - Jesse Brown / @bionicpill

12/29/2010 at 12:54AM

45
#1159 - Jon Ferrer / @jonnyheadphones

01/02/2011 at 02:45AM

45
#1160 - giggzy / @giggzy

08/13/2011 at 09:24PM

45
#1161 - Jonathan Bennett / @jonbca7

11/24/2011 at 06:21AM

45
#1162 - Sky Fernandez / @cyberjoeboy

12/14/2011 at 06:55PM

45
#1163 - Garrett Davis / @surfprimal

04/02/2012 at 10:44PM

45
#1164 - Zifei Tong / @chevalun

09/08/2012 at 11:43AM

45
#1165 - Tóth Balázs / @tthbalazs

10/25/2012 at 09:27PM

45
#1166 - Roberto Antolín / @Tolanss

03/04/2013 at 07:44PM

45
#1167 - Simon Tost / @Someone_Busy

03/09/2013 at 08:43AM

45
#1168 - Martin Keogh / @Martin1Keogh

03/31/2013 at 03:28PM

45
#1169 - Kathryn / @hartknyx

05/17/2013 at 01:44AM

45
#1170 - Andrew Noyes / @seyonwerdna

07/08/2013 at 07:09AM