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

1885 active golfers, 7658 entries

Leaderboard (lowest score wins):
34
#331 - Topvimgolf Score / @topvimgolfscore

10/12/2022 at 10:58AM

34
#332 - Zion Park / @zionpark93

12/14/2022 at 11:19AM

34
#333 - Dogu / @DoguCSGO

02/25/2023 at 10:17PM

34
#334 - Mihael Protsko / @eastaveracruz

07/31/2023 at 04:00PM

34
#335 - 이원석 / @92lwsk

09/26/2023 at 07:36AM

34
#336 - tianxiaweiyidao / @tianxiaweiyidao

04/17/2024 at 04:27PM

34
#337 - sodawithbubbles / @sodawithbubbles

05/29/2024 at 10:06AM

34
#338 - imperatormatthias / @imperatormatthias

06/18/2024 at 03:59PM

34
#339 - Suhaib Murshid / @suhaibm

08/17/2024 at 07:44AM

34
#340 - Pablo Acuna / @pacuna

10/18/2024 at 01:23AM

34
#341 - 0xf00ff00f / @0xf00ff00f

12/29/2024 at 10:51PM

34
#342 - f0tze schlampe / @Nuttnsauger5000

02/20/2025 at 10:52PM

34
#343 - Ada / @ada-nomosone

09/04/2025 at 02:04AM

34
#344 - Tim Rutter / @timrutter

11/25/2025 at 06:23PM

34
#345 - Alex Barnett / @Gullfaxi29

01/09/2026 at 04:07AM

34
#346 - speedking456 / @speedking456

03/12/2026 at 11:38AM

34
#347 - Marcel Trzaskawka / @Marcello124

04/23/2026 at 10:43PM

34
#348 - nicolas / @cnbaird

06/20/2026 at 02:57AM

34
#349 - wpr__ / @wpr____

07/19/2026 at 12:33AM

35
#350 - uuu / @uu59

12/30/2010 at 12:41AM

35
#351 - jacobangel / @jacobangel

12/31/2010 at 07:09AM

35
#352 - duckdalbe / @duckdalbe

01/14/2011 at 11:47AM

35
#353 - h_east (トロッコ6個) / @h_east

01/17/2011 at 12:59AM

35
#354 - Antony Scriven / @antonyscriven

02/05/2011 at 08:23PM

35
#355 - Mark Scholtz / @markscholtz

02/07/2011 at 08:17PM

35
#356 - David / @dpa_92

08/01/2011 at 09:09AM

35
#357 - William Dunand / @wdunand

12/13/2011 at 05:50AM

35
#358 - Paul Bourke / @brk3

12/13/2011 at 02:52PM

35
#359 - Sergio Benitez / @Sergio965

01/30/2012 at 06:50PM

35
#360 - Aaron Spiegel / @spiegela

02/05/2012 at 01:36AM