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

1792 active golfers, 7261 entries

Leaderboard (lowest score wins):
58
#1591 - Scott Myц / @ScottMuc

04/06/2013 at 05:18PM

58
#1592 - Eric Lau / @elau89

06/21/2014 at 10:11PM

58
#1593 - Brian Hall / @_bruab_

04/28/2017 at 01:12PM

58
#1594 - Benjamin Unger / @Ben_Unger

09/16/2017 at 01:41PM

58
#1595 - Daniel / @Daniel55042385

03/27/2023 at 11:42AM

58
#1596 - Jonathan Lowe / @jsl2

03/31/2024 at 10:40AM

58
#1597 - Henry / @henry-zwart

12/09/2024 at 01:17PM

58
#1598 - Backwater1 / @Backwater1

02/21/2025 at 09:28PM

58
#1599 - Jean Dubois / @jd-develop

05/11/2025 at 03:57PM

59
#1600 - Wes Maldonado / @wes

12/28/2010 at 07:41PM

59
#1601 - travis spangle / @travisspangle

12/30/2010 at 09:49PM

59
#1602 - keo / @keo

03/04/2011 at 03:55PM

59
#1603 - Fred / @fredlee

05/27/2011 at 01:10PM

59
#1604 - John Ford / @GhettoCode

02/03/2012 at 09:56PM

59
#1605 - Paul Federspiel / @parobalth

11/10/2013 at 11:22PM

59
#1606 - TimWolla / @TimWolla

03/13/2014 at 10:27PM

59
#1607 - Luis Rodriguez / @luisthecoder

11/13/2018 at 03:37AM

59
#1608 - jackmark / @jackmar14540583

07/11/2020 at 04:48AM

59
#1609 - Qishuai Liu / @LiuQishuai

01/06/2023 at 02:06PM

59
#1610 - Vimgolf User / @VimgolfU

10/16/2023 at 11:22AM

59
#1611 - CHA ~ / @CHA-CHA-CHA-EP1

01/20/2024 at 07:57AM

59
#1612 - einrock / @einrock

09/08/2024 at 05:34AM

59
#1613 - tofitsch / @tofitsch

10/06/2024 at 08:34AM

59
#1614 - MEschenbacher / @eschenbacher_m

01/02/2025 at 10:21PM

59
#1615 - skonb / @skonb

01/26/2025 at 08:24AM

59
#1616 - Ole Jan Lars Riemann / @ojlr

04/03/2025 at 03:31PM

59
#1617 - snowfarer / @snowfarer

05/25/2025 at 06:32PM

59
#1618 - Alexey Dmitriev / @AlexeyDmitriev

05/30/2025 at 08:31AM

60
#1619 - Unsouled / @unsouled0

12/30/2010 at 02:52AM

60
#1620 - Tomo.H / @joker1007

04/24/2011 at 08:01AM