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):
43
#151 - Sravan Prasad / @SravanPrasad2

03/07/2014 at 09:27PM

43
#152 - Felipe Jaramillo F / @mrfelipe

04/04/2014 at 04:00AM

43
#153 - Ram Tamtam / @ramtamtamtam

06/30/2014 at 01:14PM

43
#154 - Caek / @Caek_

08/27/2014 at 04:15AM

43
#155 - Jose Gutierrez / @Jogusa

09/19/2014 at 09:28PM

43
#156 - Mauro Persano / @fzort

11/20/2014 at 07:20PM

43
#157 - Matthieu Crapet / @mcr05

01/13/2015 at 09:24PM

43
#158 - T A / @SirAviles

09/13/2015 at 09:32PM

43
#159 - Ian Trophy / @prfrgg

01/30/2016 at 01:25PM

43
#160 - Robin Ramael / @RobinRamael

05/30/2016 at 08:40AM

43
#161 - jj johnson / @jcassj1

08/23/2016 at 01:14PM

43
#162 - Michał Dytko / @DytkoM

12/28/2016 at 01:55PM

43
#163 - Gurukandhamoorthi / @Gurukandhamoor1

07/15/2017 at 04:35PM

43
#164 - Adrian Staniec / @adrianstaniec

08/06/2017 at 05:58PM

43
#165 - xyz / @menhej

02/04/2018 at 01:06AM

43
#166 - Martynas Bardauskas / @mbardauskas

07/12/2018 at 12:47PM

43
#167 - alekfed / @alek_fed

04/16/2019 at 02:24PM

44
#168 -  Ikhsan Maulana / @ixandidu

12/29/2010 at 11:56AM

44
#169 - uuu / @uu59

12/29/2010 at 07:01PM

44
#170 - Ankit Shankar / @thelastnode

12/29/2010 at 07:45PM

44
#171 - nooodl / @nooodl

12/30/2010 at 11:05AM

44
#172 - PA Parent / @paparent

12/30/2010 at 01:08PM

44
#173 - solsTiCe d'Hiver / @solstice_dhiver

12/30/2010 at 05:28PM

44
#174 - Katie Kennedy / @cappy_haddock

12/30/2010 at 07:38PM

44
#175 - Leeward Bound / @leewardbound

12/31/2010 at 03:48PM

44
#176 - Casey W Crites / @caseycrites

01/01/2011 at 07:04AM

44
#177 - Ben Brown / @benofbrown

01/01/2011 at 07:28PM

44
#178 - Israel Chauca F. / @Raimondi

01/01/2011 at 08:59PM

44
#179 - Brad / @bjjwillis

01/02/2011 at 11:54AM

44
#180 - Olivier Verdier / @OlivierVerdier

01/03/2011 at 04:48PM