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

1754 active golfers, 7154 entries

Leaderboard (lowest score wins):
125
#1741 - Stanislav Ozeransky / @ozz-life

11/09/2024 at 03:14PM

126
#1742 - Zigmas Bitinas / @samgiz

02/11/2024 at 05:07PM

132
#1743 - Valeriy Viktorovskiy / @viktorovskiy

12/28/2010 at 11:35PM

135
#1744 - Ryan Riley Puzon / @juscuzryancan

04/03/2025 at 09:26PM

136
#1745 - edgar1437 / @edgar1437

03/10/2025 at 11:53AM

137
#1746 - Dan Reiland / @dmreiland

12/29/2010 at 09:59PM

139
#1747 - Aadi Deshpande / @cilquirm

12/29/2010 at 05:20PM

150
#1748 - Unknown / @Unknown71821287

05/30/2023 at 10:55AM

154
#1749 - Peter Önneby / @poenneby

03/28/2023 at 10:00AM

161
#1750 - Akeem Adeniji / @akeem

12/28/2010 at 11:44PM

161
#1751 - ehdckf / @ehdckf

04/15/2024 at 04:10AM

166
#1752 - Jeremy Woertink / @jeremywoertink

12/28/2010 at 09:20PM

186
#1753 - David Wang / @wangd14

01/23/2025 at 10:02PM

206
#1754 - Patrick Muldoon / @d00n

12/29/2010 at 03:12PM