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

315 active golfers, 825 entries

Leaderboard (lowest score wins):
44
#181 - Ujjwol Lamichhane / @Ujjwol

01/06/2011 at 12:44PM

44
#182 - enzbang / @enzbang

01/08/2011 at 09:07PM

44
#183 - Toto l'haricot / @nico_le_terribl

01/09/2011 at 10:42PM

44
#184 - Jes / @vim_jes

01/14/2011 at 12:29AM

44
#185 - jacobangel / @jacobangel

01/15/2011 at 06:04AM

44
#186 - Andrey A. Ugolnik / @andreyugolnik

01/19/2011 at 06:46PM

44
#187 - Matthieu Honel / @ocus

01/29/2011 at 12:51PM

44
#188 - Wesley Wong / @wesleymwwong

01/30/2011 at 10:26AM

44
#189 - xhtmlforum / @xhtmlforum

01/31/2011 at 09:32PM

44
#190 - Terje Larsen / @terlars

04/08/2011 at 12:34PM

44
#191 - arminas / @arminas

06/22/2011 at 12:36PM

44
#192 - David / @dpa_92

08/02/2011 at 12:25PM

44
#193 - こばばー / @symmet

09/28/2011 at 01:02AM

44
#194 - Christopher Brew / @Seph1rothVII

01/31/2012 at 11:48PM

44
#195 - Michael / @mjs2600

06/29/2012 at 10:32PM

44
#196 - Son of Bongo / @bpcode

09/22/2012 at 02:53AM

44
#197 - Jason Wolf / @zephyr_wolf

11/08/2012 at 05:54PM

44
#198 - Runar / @runarfu

12/03/2012 at 08:33PM

44
#199 - Michael / @patheticpat

12/17/2012 at 10:49PM

44
#200 - Bart of Denver / @bartofdenver

08/13/2013 at 03:45AM

44
#201 - Hachez Floran / @FloranHachez

09/07/2013 at 09:32AM

44
#202 - Dom Armstrong / @dom_cycleface

09/12/2013 at 12:36PM

44
#203 - Zach Kemp / @zvksf

12/13/2013 at 08:09AM

44
#204 - Endir / @Endir2

04/18/2014 at 01:39PM

44
#205 - Jacob Joaquin / @JacobJoaquin

06/30/2014 at 04:06AM

44
#206 - Haoxuan Yue / @yuehaoxuanar

07/19/2014 at 01:22PM

44
#207 - John Clara / @johnanthclara

08/24/2015 at 08:52PM

44
#208 - Andrew Michaud / @andrewjmichaud

09/04/2015 at 07:48PM

44
#209 - Gerald Tilma / @GeraldTilma

10/22/2015 at 02:12AM

44
#210 - Ryan Marcotte / @ryanjmarcotte

11/16/2015 at 02:53PM