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

382 active golfers, 1000 entries

Leaderboard (lowest score wins):
43
#151 - t__naka / @t__naka

08/07/2011 at 10:40AM

43
#152 - Xavier Nayrac / @lkdjiin

12/30/2011 at 10:18AM

43
#153 - Jyun-Fan Tsai / @fakecolor

02/11/2012 at 02:47AM

43
#154 - David Xia / @davidxia_

03/24/2012 at 01:44AM

43
#155 - Chris Penkett / @chrispenkett

04/02/2012 at 11:51PM

43
#156 - Nolen Royalty / @NolenRoyalty

04/20/2012 at 11:16PM

43
#157 - tmr / @tmr314

09/05/2012 at 06:51PM

43
#158 - T / @tea_sea

11/15/2012 at 10:47AM

43
#159 - Marcin Szamotulski / @me_coot

11/24/2012 at 12:05AM

43
#160 - ajh / @AlexJHammel

12/23/2012 at 07:29PM

43
#161 - JonLz / @LzJon

12/26/2012 at 08:22PM

43
#162 - Yann Moisan / @YannMoisan

01/22/2013 at 07:25PM

43
#163 - xavier kt / @xav_kt

02/05/2013 at 12:48AM

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

07/15/2013 at 05:20AM

43
#165 - David Pathakjee / @DavidPathakjee

08/14/2013 at 04:36AM

43
#166 - James / @Dronak

09/03/2013 at 11:27PM

43
#167 - isayoldchap / @isayoldchap

09/12/2013 at 10:18AM

43
#168 - brett / @brettyukich

09/22/2013 at 08:53AM

43
#169 - Quota / @Quotad

02/06/2014 at 11:27AM

43
#170 - João Paiva / @jgpaiva

02/10/2014 at 05:29PM

43
#171 - Sravan Prasad / @SravanPrasad2

03/07/2014 at 09:27PM

43
#172 - Felipe Jaramillo F / @mrfelipe

04/04/2014 at 04:00AM

43
#173 - Ram Tamtam / @ramtamtamtam

06/30/2014 at 01:14PM

43
#174 - Caek / @Caek_

08/27/2014 at 04:15AM

43
#175 - Jose Gutierrez / @Jogusa

09/19/2014 at 09:28PM

43
#176 - Mauro Persano / @fzort

11/20/2014 at 07:20PM

43
#177 - Matt / @mcr05

01/13/2015 at 09:24PM

43
#178 - T A / @SirAviles

09/13/2015 at 09:32PM

43
#179 - Ian Trophy / @prfrgg

01/30/2016 at 01:25PM

43
#180 - Robin Ramael / @RobinRamael

05/30/2016 at 08:40AM