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

1792 active golfers, 7261 entries

Leaderboard (lowest score wins):
46
#1231 - Herr Oppermann / @HerrOppermann

09/17/2014 at 05:00PM

46
#1232 - Mohamad Ayyash / @mkayyash

09/19/2014 at 12:02AM

46
#1233 - Ryan Glassett / @rollsavager

10/23/2014 at 12:57AM

46
#1234 - Christian Kjær / @christian_kjaer

12/13/2014 at 11:57PM

46
#1235 - adrien frediani / @fredianiadrien

12/16/2015 at 08:15PM

46
#1236 - Craig Hills / @chills42

03/05/2016 at 02:34AM

46
#1237 - Timothy Caleb Nordlo / @tnordloh

06/27/2016 at 04:45AM

46
#1238 - Michał Kordas / @michal_kordas

09/19/2016 at 07:46PM

46
#1239 - Patrick Davey / @psdavey

10/26/2016 at 12:31PM

46
#1240 - Gurukandhamoorthi / @Gurukandhamoor1

07/10/2017 at 11:52AM

46
#1241 - Terry Ding / @TerryDing77

08/24/2017 at 11:03AM

46
#1242 - Jonathan Camilleri / @Too_Many_Taken

05/24/2018 at 02:54PM

46
#1243 - Oren Koriat / @KoriatOren

12/13/2018 at 09:14PM

46
#1244 - Alexandre MERLIN / @AlxMerlin

07/05/2020 at 10:30AM

46
#1245 - Matthieu Cneude / @Cneude_Matthieu

10/19/2020 at 03:57PM

46
#1246 - Scott Atkins / @scottrick49

06/11/2021 at 01:19PM

46
#1247 - Rick de chez Gnous / @GnousRick

07/09/2021 at 11:24AM

46
#1248 - Chris Chung / @Demeter_Garden

12/08/2021 at 04:50AM

46
#1249 - Hans Wurscht / @HansW313

08/07/2022 at 08:26PM

46
#1250 - Indu Pillai / @Cute1Indu

10/03/2022 at 07:39AM

46
#1251 - test-and-sun / @testandsun1

01/10/2023 at 03:25PM

46
#1252 - lex / @aludeman

02/25/2023 at 08:35PM

46
#1253 - Ricardo Bittencourt / @ricbit

01/20/2024 at 12:25AM

46
#1254 - 吃鱼 / @xwwd9

01/29/2024 at 01:26PM

46
#1255 - Afzal Hussain / @afzalhussain23

04/10/2024 at 10:36AM

46
#1256 - Michael Kebe / @michaelkebe

10/15/2024 at 07:08AM

46
#1257 - rqdmap / @rqdmap

02/26/2025 at 12:20PM

47
#1258 - Felipe Nakandakari / @fenak

12/28/2010 at 09:32PM

47
#1259 - Ben Lenarts / @benlenarts

12/29/2010 at 04:07PM

47
#1260 - Thomas Schönwälder / @Masei1988

01/15/2011 at 06:17PM