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 4d1b1b97c58eaa2a8a0002fc

Python Hello World! Reformatting

A novice Python using prints Hello World! and a pro shows him different way. Using vim to get into pro style from novice, win the challenge.

Start file
#!/usr/bin/python
import sys
a
= "Hello World!"
sys
.stdout.write(str(a[0]))
sys
.stdout.write(str(a[1]))
sys
.stdout.write(str(a[2]))
sys
.stdout.write(str(a[3]))
sys
.stdout.write(str(a[4]))
sys
.stdout.write(str(a[5]))
sys
.stdout.write(str(a[6]))
sys
.stdout.write(str(a[7]))
sys
.stdout.write(str(a[8]))
sys
.stdout.write(str(a[9]))
sys
.stdout.write(str(a[10]))
sys
.stdout.write(str(a[11]))
End file
#!/usr/bin/python
import sys
a
= "Hello World!"
for i in range(0, len(a)):
  sys
.stdout.write(str(a[i]))

View Diff

4,15c4,5
< sys.stdout.write(str(a[0]))
< sys.stdout.write(str(a[1]))
< sys.stdout.write(str(a[2]))
< sys.stdout.write(str(a[3]))
< sys.stdout.write(str(a[4]))
< sys.stdout.write(str(a[5]))
< sys.stdout.write(str(a[6]))
< sys.stdout.write(str(a[7]))
< sys.stdout.write(str(a[8]))
< sys.stdout.write(str(a[9]))
< sys.stdout.write(str(a[10]))
< sys.stdout.write(str(a[11]))
---
> for i in range(0, len(a)):
>   sys.stdout.write(str(a[i]))

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 381 remaining solutions by signing in and submitting your own entry
#382 Zhao Yao / @Lynch8080 - Score: 93 - 12/31/10 @ 17:33
jjj12ddofor i in range()<Esc>i0, len()<Esc>ia<Esc>$a:<CR><BS>  sysy<BS>.stu<BS>dout.write()<Esc>istr()<Esc>ia[]<Esc>ii<Esc>:wq<CR>

0 comments


Created by: @Ujjwol

382 active golfers, 1000 entries

Leaderboard (lowest score wins):
42
#121 - ren / @wxoc

07/10/2014 at 08:34AM

42
#122 - r. / @rmarvie

12/20/2014 at 08:37PM

42
#123 - Alex Bartol / @alexbartol

05/06/2015 at 06:25AM

42
#124 - Mauro Persano / @fzort

05/25/2015 at 01:49AM

42
#125 - Joel Gallant / @joelg236

07/16/2015 at 04:20PM

42
#126 - Walker Boh / @walker_boh

10/14/2015 at 09:07AM

42
#127 - tPenguinLTG / @tpenguinltg

05/13/2016 at 02:10AM

42
#128 - Will / @obiwan__k3n00bi

08/23/2016 at 01:07AM

42
#129 - Florian Gauger / @FlorianGauger

06/05/2017 at 10:35PM

42
#130 - albalitz / @_albalitz

06/14/2019 at 01:02PM

42
#131 - majo senf / @majo_senf

06/25/2019 at 08:18AM

42
#132 - Березницкий Вадим / @vad1mster

07/09/2019 at 12:20PM

42
#133 - relastle / @relastle

03/30/2020 at 05:23AM

42
#134 - Levi Wheeler / @LeviWhe68726437

06/14/2022 at 11:01PM

42
#135 - Jake Popham / @jpopham91

03/08/2023 at 03:43AM

42
#136 - Jonathan Schaaij / @jonathanschaaij

08/23/2024 at 01:13PM

43
#137 - libicocco / @libicocco

12/29/2010 at 12:29PM

43
#138 - Marian Schubert / @MarianSchubert

12/29/2010 at 12:45PM

43
#139 - Tudor Golubenco / @tudor_g

12/29/2010 at 01:18PM

43
#140 - Indrek Juhkam / @indrekj

12/29/2010 at 04:16PM

43
#141 - Dmytro Shteflyuk / @kpumuk

12/29/2010 at 04:24PM

43
#142 - Christoph Stock / @christophstock

12/29/2010 at 11:12PM

43
#143 - greg / @kongo2002

12/31/2010 at 12:06AM

43
#144 - Rörd Hinrichsen / @roerdhh

01/09/2011 at 11:15PM

43
#145 - Francisco Dibar / @frandibar

01/13/2011 at 04:38AM

43
#146 - Eivind Jahren / @HaskellElephant

01/27/2011 at 05:55PM

43
#147 - Grai / @haybeesea

02/13/2011 at 10:39PM

43
#148 - wusher / @wusher

06/01/2011 at 02:23AM

43
#149 - Rolf K. / @mindleftbody

06/17/2011 at 02:02PM

43
#150 - Dave / @zzdave13

07/31/2011 at 09:50PM