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

327 active golfers, 857 entries

Leaderboard (lowest score wins):
47
#271 - Alex B. / @SIGKILL

12/29/2010 at 01:30PM

47
#272 - Joe Hassick / @jhassick

12/29/2010 at 08:48PM

47
#273 - Ben Dowling / @coderholic

12/31/2010 at 08:30PM

47
#274 - R. P. Fainmen / @4loops

01/07/2011 at 08:53PM

47
#275 - ae7o / @ae7o

04/29/2011 at 09:30PM

47
#276 - Øystein Walle / @oysteinwalle

07/12/2011 at 03:25PM

47
#277 - Tj / @yrddy

08/19/2014 at 10:38AM

47
#278 - Darkhan / @d4rkh4n

02/03/2016 at 10:39AM

48
#279 - Daniel Dourvaris / @dourvaris

12/29/2010 at 02:08PM

48
#280 - Abhinav Gupta / @ag90

12/29/2010 at 03:02PM

48
#281 - Aaron Bull Schaefer / @elasticdog

12/29/2010 at 04:23PM

48
#282 - Andrew McDonough / @andrewmcdonough

12/29/2010 at 06:32PM

48
#283 - Roland Crosby / @roooooland

12/30/2010 at 08:40AM

48
#284 - Mikel Ward / @mikelward

12/30/2010 at 10:01AM

48
#285 - jonbell17 / @jonbell17

12/30/2010 at 08:03PM

48
#286 - drio / @drio

01/02/2011 at 02:00PM

49
#287 - Jan B. / @bracki

12/29/2010 at 12:06PM

49
#288 - Lasse Højgaard / @lhojgaard

12/29/2010 at 12:32PM

49
#289 - Drew Neil / @nelstrom

12/29/2010 at 01:28PM

49
#290 - Chris Flynn / @flynnguy

12/29/2010 at 04:14PM

49
#291 - Andrei Chirila / @andrei_chirila

12/30/2010 at 04:18PM

49
#292 - Ryan Kanno / @ryankanno

01/07/2011 at 07:54AM

49
#293 - Stephen Gordon / @DubsGordon

08/01/2011 at 11:28PM

49
#294 - Aaron Josephs / @aaronjosephs1

05/02/2013 at 02:18AM

49
#295 - Sebastian / @dersharky

05/12/2020 at 08:21PM

50
#296 - Aleksander Balicki / @alekbalicki

12/29/2010 at 02:11PM

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

12/29/2010 at 04:04PM

50
#298 - Jack Kordas / @JackKordas

12/29/2010 at 04:08PM

50
#299 - Alain Gilbert / @alain_gilbert

12/30/2010 at 06:09AM

51
#300 - Linus G Thiel / @yesbabyyes

12/29/2010 at 01:55PM