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):
39
#781 - Filipe Brandenburger / @filbranden

05/28/2021 at 04:11PM

39
#782 - Patrick Gates / @patrickgates

06/14/2021 at 11:25PM

39
#783 - Adam / @Adam75625825

06/29/2021 at 03:51PM

39
#784 - Sean Cahill / @ess_jay_kay

10/26/2021 at 04:53PM

39
#785 - unchi / @unchi10723002

05/07/2022 at 06:44AM

39
#786 - quemeraisc / @quemeraisc

05/19/2022 at 03:34PM

39
#787 - Eric Ewing / @CoordinateRobos

11/06/2022 at 02:07AM

39
#788 - Gs Abl / @gs_abl

07/08/2023 at 03:33PM

39
#789 - VinniesVimGolf / @GolfVim56952

07/27/2023 at 10:05PM

39
#790 - s yakisoba / @s_syakisoba

09/02/2023 at 06:22AM

39
#791 - ye-chuan / @ye-chuan

01/24/2024 at 11:48AM

39
#792 - TobSick / @TobSick

06/05/2024 at 01:02PM

39
#793 - Tsimon Dorakh / @Tsimon-Dorakh

07/31/2024 at 07:49PM

39
#794 - Horace He / @Chillee

10/04/2024 at 06:04AM

39
#795 - Pim / @Pireax

11/08/2024 at 12:34AM

39
#796 - martys71 / @martys71

12/05/2024 at 10:06PM

39
#797 - ๐•๐• ๐•–๐•ช โ„ค๐•™๐•–๐•Ÿ๐•˜ / @joey5403

04/27/2025 at 11:46AM

40
#798 - Brad Grzesiak / @listrophy

12/28/2010 at 08:10PM

40
#799 - David Shaw / @shawthings

12/30/2010 at 10:18AM

40
#800 - Fitz / @Fitzface

12/31/2010 at 03:11PM

40
#801 - Roman Maลกek / @romario333

01/02/2011 at 06:16PM

40
#802 - Grigoriy Glushko / @grinderrz

01/05/2011 at 12:36PM

40
#803 - aimee / @sermoa

01/08/2011 at 02:21PM

40
#804 - James Edward Gray II / @JEG2

04/04/2011 at 12:56AM

40
#805 - Shawn / @sartak

04/22/2011 at 10:50PM

40
#806 - Lauri Tirkkonen / @lotheac

07/01/2011 at 11:17PM

40
#807 - Kubek2k / @kubek2k

09/29/2011 at 10:33PM

40
#808 - johan wester / @wester87

11/12/2011 at 04:27PM

40
#809 - Travis Jeffery / @travisjeffery

12/07/2011 at 12:25AM

40
#810 - Kristopher Urie / @kristopherurie

02/09/2012 at 02:39AM