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

319 active golfers, 832 entries

Leaderboard (lowest score wins):
43
#121 - Marian Schubert / @MarianSchubert

12/29/2010 at 12:45PM

43
#122 - Tudor Golubenco / @tudor_g

12/29/2010 at 01:18PM

43
#123 - Indrek Juhkam / @indrekj

12/29/2010 at 04:16PM

43
#124 - Dmytro Shteflyuk / @kpumuk

12/29/2010 at 04:24PM

43
#125 - Christoph Stock / @christophstock

12/29/2010 at 11:12PM

43
#126 - greg / @kongo2002

12/31/2010 at 12:06AM

43
#127 - Rörd Hinrichsen / @roerdhh

01/09/2011 at 11:15PM

43
#128 - Francisco Dibar / @frandibar

01/13/2011 at 04:38AM

43
#129 - Eivind Jahren / @HaskellElephant

01/27/2011 at 05:55PM

43
#130 - Grai / @haybeesea

02/13/2011 at 10:39PM

43
#131 - wusher / @wusher

06/01/2011 at 02:23AM

43
#132 - Rolf K. / @mindleftbody

06/17/2011 at 02:02PM

43
#133 - Dave / @zzdave13

07/31/2011 at 09:50PM

43
#134 - t__naka / @t__naka

08/07/2011 at 10:40AM

43
#135 - Xavier Nayrac / @lkdjiin

12/30/2011 at 10:18AM

43
#136 - Jyun-Fan Tsai / @fakecolor

02/11/2012 at 02:47AM

43
#137 - David Xia / @davidxia_

03/24/2012 at 01:44AM

43
#138 - Chris Penkett / @chrispenkett

04/02/2012 at 11:51PM

43
#139 - Nolen Royalty / @NolenRoyalty

04/20/2012 at 11:16PM

43
#140 - tmr / @tmr314

09/05/2012 at 06:51PM

43
#141 - Tom Cammann / @tea_sea

11/15/2012 at 10:47AM

43
#142 - Marcin Sza / @coot_

11/24/2012 at 12:05AM

43
#143 - Alex Hammel / @AlexJHammel

12/23/2012 at 07:29PM

43
#144 - JonLz / @LzJon

12/26/2012 at 08:22PM

43
#145 - Yann Moisan / @YannMoisan

01/22/2013 at 07:25PM

43
#146 - xavier kt / @xav_kt

02/05/2013 at 12:48AM

43
#147 - Woojung Kim 김우중 / @_kimwz

07/15/2013 at 05:20AM

43
#148 - David Pathakjee / @DavidPathakjee

08/14/2013 at 04:36AM

43
#149 - James / @Dronak

09/03/2013 at 11:27PM

43
#150 - isayoldchap / @isayoldchap

09/12/2013 at 10:18AM