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):
42
#91 - mightyfoo / @mightyfoo

05/26/2011 at 10:33AM

42
#92 - Jim Infield / @jinfield

07/20/2011 at 06:56PM

42
#93 - Neil / @spameldoon

08/21/2011 at 12:03AM

42
#94 - Daniel Hjerth / @danielhjerth

11/09/2011 at 05:12PM

42
#95 - William Dunand / @wdunand

12/02/2011 at 08:17AM

42
#96 - Ashley Feniello / @AshleyFen

01/29/2012 at 05:46AM

42
#97 - snuffling / @snuffling

02/13/2012 at 05:30AM

42
#98 - 無ん垢の叫び / @john_ababa

02/23/2012 at 08:29AM

42
#99 - Chris Brown / @engineercyb

07/31/2012 at 08:21PM

42
#100 - Dan Oneata / @DanOneata

08/04/2012 at 10:14AM

42
#101 - 4L41N / @4L41N1

11/09/2012 at 09:51AM

42
#102 - Kenneth Waters / @gen_witt

11/13/2012 at 09:42PM

42
#103 - André / @Joschasa

12/24/2012 at 09:51PM

42
#104 - Rasmus Prentow / @rasmusprentow

05/13/2013 at 11:55AM

42
#105 - Dr. Rev. J. "Paranoid Android" Kirchartz / @JKirchartz

07/21/2013 at 01:46PM

42
#106 - Fernando Axel Ellis / @Axel_Ellis

09/13/2013 at 09:12PM

42
#107 - Stephen Drodge / @sjdrodge

10/08/2013 at 03:04AM

42
#108 - ren / @wxoc

07/10/2014 at 08:34AM

42
#109 - r. / @rmarvie

12/20/2014 at 08:37PM

42
#110 - Alex Bartol / @alexbartol

05/06/2015 at 06:25AM

42
#111 - Mauro Persano / @fzort

05/25/2015 at 01:49AM

42
#112 - Joel Gallant / @joelg236

07/16/2015 at 04:20PM

42
#113 - Walker Boh / @walker_boh

10/14/2015 at 09:07AM

42
#114 - tPenguinLTG / @tpenguinltg

05/13/2016 at 02:10AM

42
#115 - Will / @obiwan__k3n00bi

08/23/2016 at 01:07AM

42
#116 - Florian Gauger / @FlorianGauger

06/05/2017 at 10:35PM

42
#117 - albalitz / @_albalitz

06/14/2019 at 01:02PM

42
#118 - majo senf / @majo_senf

06/25/2019 at 08:18AM

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

07/09/2019 at 12:20PM

43
#120 - libicocco / @libicocco

12/29/2010 at 12:29PM