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 4d42cde1e6dc010cb7000024

expand a list comprehension (python)

Please show your way to convert a list comprehension in python to an ordinary for-loop expression!

Start file
print [x**2 for x in xrange(10)]
End file
tmp = []
for x in xrange(10):
    tmp.append(x**2)
print tmp

View Diff

1c1,4
< print [x**2 for x in xrange(10)]
---
> tmp = []
> for x in xrange(10):
>     tmp.append(x**2)
> print tmp

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 99 remaining solutions by signing in and submitting your own entry
#100 David Burns / @AutomatedTester - Score: 146 - 01/28/11 @ 15:17
itmp = []<CR><Esc><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right>v<Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right>x<Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left>pu<Left>o<Up><CR><Up><Esc>pi<Right>:<Down><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><CR><Up><Tab><BS>    tmp.append(<Esc><Down><Right>v<Right><Right><Right>x<Up>pi<Right>)<Down><BS><BS><BS>tmp<Esc><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left>dw<Down>dd:wq<CR>

0 comments


Created by: @vimgolfer

100 active golfers, 267 entries

Leaderboard (lowest score wins):
70
#91 - Arto Vuori / @dhpe

09/01/2012 at 04:50PM

72
#92 - Vernon Thommeret / @synotic

01/30/2011 at 03:38PM

72
#93 - Christopher Brew / @Seph1rothVII

01/11/2012 at 12:41AM

73
#94 - Pavlo Klets / @p01nt

01/28/2011 at 03:27PM

75
#95 - Franco Lazzarino / @flazz

01/29/2011 at 12:51AM

75
#96 - grizzancs / @grizzancs

01/31/2011 at 12:13PM

79
#97 - Solomon White / @rubysolo

01/28/2011 at 04:58PM

104
#98 - Reza Lotun / @rlotun

01/30/2011 at 06:32PM

141
#99 - Ilya Grigorik / @igrigorik

02/01/2011 at 12:43AM

146
#100 - David Burns / @AutomatedTester

01/28/2011 at 03:17PM