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):
38
#661 - RustingSword / @RustingSword

08/18/2017 at 01:51AM

38
#662 - Mihai / @mihaicristiant

12/03/2018 at 10:32AM

38
#663 - Timur Celik / @clktmr

12/21/2018 at 04:54PM

38
#664 - Andreas Nordahl / @andreasnordahl

01/03/2019 at 10:24AM

38
#665 - abgalphabet / @abgalphabet

01/19/2019 at 04:00PM

38
#666 - Sebastien Nicoud / @sebnukem

02/11/2019 at 01:52AM

38
#667 - Danny O'Sullivan / @db0s

04/02/2019 at 08:02PM

38
#668 - mkaminaga / @mkmng3

06/28/2019 at 08:25AM

38
#669 - Ron Holt / @ron_holt

08/07/2019 at 10:42PM

38
#670 - sooqua / @sooqua

08/08/2019 at 09:14PM

38
#671 - Adam Hartz / @awareofnow

08/28/2019 at 02:07AM

38
#672 - Cassandra / @kascein

09/17/2019 at 07:11PM

38
#673 - nefforr / @yayamip

09/25/2019 at 03:48AM

38
#674 - Viktor Styrud / @ViktorStyrud

10/07/2019 at 01:16PM

38
#675 - Felix / @motorente

06/27/2020 at 07:08AM

38
#676 - Tobi Tesuji / @TobiTesuji

05/15/2021 at 09:31PM

38
#677 - Lynn / @chordbug

08/02/2021 at 06:47PM

38
#678 - Jean George / @JeanGeo20504212

09/18/2021 at 07:48PM

38
#679 - kulabun / @kulabun

09/30/2022 at 06:58AM

38
#680 - vuems / @vuems2win

11/23/2022 at 12:31AM

38
#681 - Matteo Smaila / @matthews314

01/02/2024 at 12:30AM

38
#682 - shannon / @ShannonGu1031

05/25/2024 at 12:19PM

38
#683 - shulva / @shulva

09/20/2024 at 04:19PM

38
#684 - bounce114 / @bounce114

12/01/2024 at 06:58AM

38
#685 - interminable007 / @interminable007

01/02/2025 at 09:43AM

38
#686 - Sergii Pidgornyi / @spodgorn

02/12/2025 at 11:14PM

38
#687 - Johan Kristiansson / @johankri

02/22/2025 at 10:00AM

38
#688 - Stanley Gao / @gaosu2718

03/05/2025 at 02:49PM

38
#689 - Chris Irwin / @pianowow

05/18/2025 at 11:49PM

39
#690 - Mirosław Boruta / @m1rk00

12/28/2010 at 08:41PM