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):
47
#271 - Tj / @yrddy

08/19/2014 at 10:38AM

47
#272 - Darkhan / @d4rkh4n

02/03/2016 at 10:39AM

48
#273 - Daniel Dourvaris / @dourvaris

12/29/2010 at 02:08PM

48
#274 - Abhinav Gupta / @ag90

12/29/2010 at 03:02PM

48
#275 - Aaron Bull Schaefer / @elasticdog

12/29/2010 at 04:23PM

48
#276 - Andrew McDonough / @andrewmcdonough

12/29/2010 at 06:32PM

48
#277 - Roland Crosby / @roooooland

12/30/2010 at 08:40AM

48
#278 - Mikel Ward / @mikelward

12/30/2010 at 10:01AM

48
#279 - jonbell17 / @jonbell17

12/30/2010 at 08:03PM

48
#280 - drio / @drio

01/02/2011 at 02:00PM

49
#281 - Jan B. / @bracki

12/29/2010 at 12:06PM

49
#282 - Lasse Højgaard / @lhojgaard

12/29/2010 at 12:32PM

49
#283 - Drew Neil / @nelstrom

12/29/2010 at 01:28PM

49
#284 - Chris Flynn / @flynnguy

12/29/2010 at 04:14PM

49
#285 - Andrei Chirila / @andrei_chirila

12/30/2010 at 04:18PM

49
#286 - Ryan Kanno / @ryankanno

01/07/2011 at 07:54AM

49
#287 - Stephen Gordon / @DubsGordon

08/01/2011 at 11:28PM

49
#288 - Aaron Josephs / @aaronjosephs1

05/02/2013 at 02:18AM

50
#289 - Aleksander Balicki / @alekbalicki

12/29/2010 at 02:11PM

50
#290 - Dezső Zoltán / @zakiazigazi

12/29/2010 at 04:04PM

50
#291 - Jack Kordas / @JackKordas

12/29/2010 at 04:08PM

50
#292 - Alain Gilbert / @alain_gilbert

12/30/2010 at 06:09AM

51
#293 - Linus G Thiel / @yesbabyyes

12/29/2010 at 01:55PM

51
#294 - Boris Barroso / @borisb

12/29/2010 at 07:27PM

51
#295 - cracoucax / @cracoucax

12/30/2010 at 11:00AM

51
#296 - Su. / @0moMi

12/31/2010 at 12:16AM

51
#297 - RobertT / @techrt2050

09/22/2013 at 05:18AM

51
#298 - Benjamin Kiefer / @bkiefs

04/18/2019 at 08:53PM

52
#299 - Nacho Barrientos / @nachobarrientos

12/29/2010 at 12:25PM

53
#300 - Chris Faulkner / @bookdarts

12/29/2010 at 12:34PM