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

1835 active golfers, 7462 entries

Leaderboard (lowest score wins):
37
#571 - Teemu Okkonen / @TeemuOkkonen

07/10/2015 at 08:19PM

37
#572 - Bogumił Kamiński / @BogumilKaminski

10/25/2015 at 04:02PM

37
#573 - Ben Hill / @KaizenSoze70

05/09/2016 at 01:07PM

37
#574 - Chris Armstrong / @ChrisATweets

05/20/2016 at 06:47PM

37
#575 - 王运 / @640138017

07/18/2016 at 01:56PM

37
#576 - Herbert S. / @herbertshlong

08/10/2016 at 12:31AM

37
#577 - mebubo / @mebubo

10/30/2016 at 12:18AM

37
#578 - Tom Houlé / @_tomhoule

05/15/2017 at 12:07PM

37
#579 - John Oleksowicz / @JohnOlek

10/09/2018 at 07:56PM

37
#580 - name / @name65894813

11/16/2018 at 04:44PM

37
#581 - hbdgr / @t_hbdgr

01/26/2019 at 08:07PM

37
#582 - 默罕默德 / @Rt6RjEAJ987Woes

02/20/2019 at 03:21AM

37
#583 - wanghbxxxx / @wanghbxxxx

04/07/2019 at 01:27PM

37
#584 - james_bunch / @james_bunch

04/20/2019 at 05:58AM

37
#585 - お薬手帳 / @iW4Wz6PpCiqyGqH

04/24/2019 at 05:54AM

37
#586 - Miłosz Łakomy / @foobar01123

07/08/2019 at 09:41AM

37
#587 - Vladimir Leskov / @vladimirlesk

10/12/2019 at 12:01PM

37
#588 - BnnGolfer / @BnnGolfer

03/31/2020 at 06:49PM

37
#589 - Valdimar / @genkobar

06/08/2020 at 10:35PM

37
#590 - A A A / @37fatos

01/12/2021 at 02:23AM

37
#591 - july9793 / @july9793_

01/06/2022 at 12:33PM

37
#592 - yancy / @yancy_dong

04/29/2022 at 03:47AM

37
#593 - Qing Liu / @poeminlash

06/29/2022 at 02:22AM

37
#594 - Buatvimgolf / @buatvimgolf

07/28/2022 at 05:25AM

37
#595 - Bangash💉💉 / @DevotionGeo

10/08/2022 at 03:05AM

37
#596 - Youngchan Lee / @edwardycl

12/15/2022 at 07:05AM

37
#597 - Vgaccount645 / @vgaccount616132

05/10/2023 at 12:03AM

37
#598 - rayx / @ray-x

12/05/2023 at 11:37AM

37
#599 - 5S-MOHAMED-SHABAIK / @5S-MOHAMED-SHABAIK

01/12/2024 at 03:31PM

37
#600 - TheOdd / @TheOdd

02/03/2024 at 07:43PM