Real Vim ninjas count every keystroke - do you?

Pick a challenge, fire up Vim, and show us what you got.

Leaderboard, 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 63 remaining solutions by signing in and submitting your own entry
#64 Matthieu Honel / @ocus - Score: 66 - 01/28/11 @ 07:31
itmp = []<CR><Esc>vf "axxvf "bx$r:otmp.append(<Esc>"bpi)<CR><Esc>"apAtmp<Esc>k<<i    <Esc>ZZ

0 comments

#65 Helder Inacio / @inaciohj - Score: 67 - 02/02/11 @ 19:32
dwo<Esc>pkxdt]<Esc>o<Esc>pA:<Esc>khdi[jo<C-U><Esc>4a <Esc>atmp.apped<C-H>nd()<Esc>Pjatmp<Esc>ggItmp = <Esc>:wq<CR>

0 comments

#66 Torben Rasmussen / @rasmustorben - Score: 67 - 08/16/11 @ 09:34
witmp<NL><Esc>..lv$hhdkJa= <Esc>kp0fxi.append(<Esc>Ea)<Del><NL><Esc>A:<Esc>k4I <Esc>ddpggddGpkddggPZZ

0 comments

#67 Dmitry Teslenko / @krab_mozga - Score: 69 - 02/02/11 @ 01:43
witmp<Esc>yiwwpa.append(<Esc>/2<CR>a)<Esc>?[<CR>i<Esc>pa = <Esc>?t<CR>d$O<Esc>pdn<Esc>o<Esc>pa:<Esc>?f<CR>d^o<Esc>px^4PZZ

0 comments

#68 Jon Bettinger / @jonbettinger - Score: 70 - 01/30/11 @ 18:35
ffi<CR><Esc>3XXx$r:<CR>o    tmp.append(x**2)<CR>print tmp<Esc>^XXXX:q<BS>1<CR>Ditmp = []<Esc>:wq<CR>

0 comments

#69 stefan otte / @stefanotte - Score: 70 - 01/30/12 @ 05:39
itmp <Esc>ww.i<CR><Esc>veE<Right>xpuo<Esc>p<Up>A<BS>:<Esc><Down>I    tmp.append(<Del><Esc>A<BS>u<BS>)<Esc>ggwi= []<CR><Esc>dd<Down>p:wq<CR>

0 comments

#70 Arto Vuori / @dhpe - Score: 70 - 09/01/12 @ 09:50
Itmp = []<CR><Esc>kywjfxPi.append(<Del><Esc>f r)o<Esc>p<Esc>xkdiwjPa <Esc>kffdf)O<Esc>pa:<Esc>jxF[x3i <Esc>ZZ

0 comments

#71 Vernon Thommeret / @synotic - Score: 72 - 01/30/11 @ 07:38
ffdf)o<Esc>pkFx4xjo    tmp.append(<Esc>pa)<CR>p<BS><BS><BS><BS><BS>print tmp<Esc>ggciwtmp =<Esc>3lxj$a:<Esc>ZZ

0 comments

#72 Christopher Brew / @Seph1rothVII - Score: 72 - 01/10/12 @ 16:41
dWo<Esc>pi<Right>tmp<Esc>bywggP<Right>i<CR>    <Esc><Right>puui<CR>    <Esc>pi<Right>.append<Esc><Right>r(W<Left>r)<Right>d$<Up>i<Right> = []<CR><Esc>pr:ZZ

0 comments

#73 Pasha Klets / @p01nt - Score: 73 - 01/28/11 @ 07:27
dwo<Esc>patmp<Esc><Left><Left>ywO<Esc>4i <Esc>pa.appent<BS>d()<Esc><Up>$x^p<Left>2xO<Esc>p^itmp = <Esc><Down>^3dw:<Esc>^$a:<Esc><Down>Px:wq<CR>

0 comments

#74 Franco Lazzarino / @flazz - Score: 75 - 01/28/11 @ 16:51
ea tmp =<Esc>bywPi<CR><Esc>kddp<Esc>Otmp.append()<Esc>kdi]<Esc>o<Esc>pa:<Esc>0d/for<CR>/(n<BS><CR>P<Esc>ujP<Esc>I    <Esc>f xZZ

0 comments

#75 grizzancs / @grizzancs - Score: 75 - 01/31/11 @ 04:13
Ctmp = []<CR>for x in xrange(10):<CR>tmp.append(x**2)<Esc><<i    <Esc>o<BS><BS><BS><BS>print tmp<Esc>:wq<CR>

0 comments

#76 Solomon White / @rubysolo - Score: 79 - 01/28/11 @ 08:58
/f<CR>hs<CR><Esc>$s:<Esc>kddp<Esc>els<CR><Esc>kddp<Esc>ks    tmp.append(<Esc>A)<Esc>ja tmep<BS><BS>p<Esc>ggOtmp = []<Esc>jnd0<Esc>:wq<CR>

0 comments

#77 Reza Lotun / @rlotun - Score: 104 - 01/30/11 @ 10:32
wwwwwv$hhlda<CR><BS><BS><Esc>pxkVdpxxxxxxxi    tmp.append(<Esc>$a<BS>)<Esc>ka:<Esc>ja<Esc>0Gggi<CR><Esc>ktmp<Esc>x<Esc>itmp = []<Esc>G$a<CR><BS><BS><BS><BS>print tmp<Esc>:wq<CR>

0 comments

#78 Ilya Grigorik / @igrigorik - Score: 141 - 01/31/11 @ 16:43
i<CR><Up>tmp = []<Down><Esc>ddi<Esc>ofor x in xrange(10):<CR>    tmp.append(x**2)<CR>print tmp<Esc>u:set paste<CR>i<Esc>ofor x in xrange(10):<CR>    tmp.append(x**2)<CR>print tmp<Esc>:wq<CR>

0 comments

#79 David Burns / @AutomatedTester - Score: 146 - 01/28/11 @ 07: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

79 active golfers, 202 entries

Leaderboard (lowest score wins):
X_normal
42
#1 - xhtmlforum / @xhtmlforum

01/28/2011 at 02:51PM

Image_normal
42
#2 - Pete Johns / @johnsyweb

01/28/2011 at 04:48PM

T_e_normal
42
#3 - Tim Chase / @gumnos

01/28/2011 at 04:56PM

Gravatar_normal
42
#4 - Stephen Morrow / @yawmark

01/29/2011 at 06:48AM

Me-small_normal
42
#5 - Wei Dai / @clvv42

01/29/2011 at 07:58PM

4_normal
42
#6 - Oleg Roshupkin / @jjjahson

02/01/2011 at 03:39AM

The-milky-way-mardi-khola-007_normal
42
#7 - Ujjwol Lamichhane / @Ujjwol

02/02/2011 at 06:58PM

Adept_normal
42
#8 - Balkoth / @_Balkoth_

02/03/2011 at 01:45PM

Avatar-small_normal
42
#9 - Hu Junfeng / @hujunfeng

08/01/2011 at 07:42AM

Gintoki_normal
42
#10 - You-Siang Lin / @yslinnctu

11/29/2011 at 09:39PM

Q6hrg93p4r3hn56thmd0_normal
42
#11 - Urtica dioica / @udioica

12/15/2012 at 08:24PM

Fepic_normal
43
#12 - Federico Galassi / @federicogalassi

01/28/2011 at 01:52PM

174636_220779885077_2341947_n_normal
43
#13 - flo / @c4p0ne

01/31/2011 at 05:06AM

Jlove201003sq_normal
43
#14 - Justin Love / @wondible

09/07/2011 at 05:54AM

Default_profile_5_normal
43
#15 - Rändöm Tester / @mevcar

02/12/2012 at 07:59AM

Default_profile_6_normal
43
#16 - William Dunand / @wdunand

03/06/2012 at 12:34AM

N1124384283_4989_normal
44
#17 - Michał Taszycki / @mehowte

01/29/2011 at 10:51AM

P1000007_normal
46
#18 - h_east (DDD ready) / @h_east

01/28/2011 at 11:26PM

Avatar-square_normal
47
#19 - Zak Johnson / @zakj

04/20/2011 at 06:41PM

Avatar_normal
47
#20 - Øystein Walle / @oysteinwalle

07/08/2011 at 01:15PM

Default_profile_2_normal
47
#21 - Renat Aksitov / @Korvin79

02/26/2012 at 10:30AM

4654945923_eb2c60ee5f_normal
47
#22 - Kerson Hsiao / @KersonHsiao

08/02/2012 at 08:45PM

Default_profile_0_normal
48
#23 - timhoa / @timhoa

01/29/2011 at 01:14PM

Rebrik_small_normal
48
#24 - Ivan Nečas / @iNecas

01/31/2011 at 02:56PM

Default_profile_6_normal
48
#25 - Christopher Erin / @Chris__Erin

09/26/2011 at 05:36PM

Avatar_normal
49
#26 - Xavier Nayrac / @lkdjiin

01/08/2012 at 03:35AM

Dude2_normal
50
#27 - Eivind Jahren / @HaskellElephant

02/02/2011 at 02:14PM

Allah-final_normal
50
#28 - Ibrahim Tencer / @ibrahimtencer

02/12/2012 at 08:40PM

2c68d2a7e6b253e55d7ded4abb4710d1_normal
50
#29 - Yann Moisan / @YannMoisan

01/13/2013 at 11:57AM

46a0320167ab007f0a98222e65c0f3b7_normal
51
#30 - Dan Masquelier / @danmasq

07/01/2011 at 02:32PM

Gravatar_normal
51
#31 - Jesús Espino / @jespinog

09/06/2011 at 03:29PM

Bc879469f279ee24b7fbdfad7c2216d9_normal
51
#32 - 無ん垢の叫び / @john_ababa

02/27/2012 at 12:04AM

Twitterprofile_normal
51
#33 - Daniel Erlandsson / @danneerlandsson

05/11/2012 at 05:20AM

Jpiasetzki_normal
51
#34 - John Piasetzki / @jpiasetz

07/13/2012 at 12:03AM

Default_profile_2_normal
52
#35 - iCross / @iCrossOfficial

01/30/2011 at 11:46AM

Default_profile_3_normal
52
#36 - Thom Hughes / @thom_hughes_1

03/27/2011 at 06:42AM

264327_10150230576896345_729061344_7523848_5517118_n_normal
52
#37 - Nolen Royalty / @NolenRoyalty

04/20/2012 at 11:25AM

Cv_normal
53
#38 - Ben Sinclair / @muppling

02/07/2011 at 12:22PM

Default_profile_3_normal
53
#39 - Arthur Hinh / @arthur_hinh

03/25/2011 at 09:20PM

Default_profile_2_normal
53
#40 - Avinash Baliga / @avinashbaliga

03/27/2011 at 01:41PM

Madmen_artem_normal
54
#41 - Artem Dudarev / @dudarev

01/30/2011 at 08:25AM

Foto_joost_normal
54
#42 - Joost / @vlabakje

02/11/2011 at 04:29PM

Profile2_normal
54
#43 - Nicola Paolucci / @durdn

02/25/2011 at 01:04PM

Profile_normal
55
#44 - Jay Phillips / @jicksta

01/30/2011 at 01:15PM

Chris_beard_normal
55
#45 - Chris Penkett / @chrispenkett

04/03/2012 at 11:57AM

Default_profile_5_normal
56
#46 - Matti Hänninen / @mjhanninen

01/30/2011 at 01:35PM

Sup-av_normal
56
#47 - Ian McCowan / @valrus

05/29/2011 at 01:34PM

Uwe_horns_by_joao_normal
56
#48 - Dave / @zzdave13

07/18/2011 at 02:29PM

T_normal
56
#49 - Ayose Cazorla / @ayosec

09/03/2011 at 09:03AM

Lightingcat_normal
57
#50 - Amy Ciavolino / @imightbeAmy

02/15/2013 at 09:47AM

E45ce5cdab423eaaeefc7c38c2381139_normal
58
#51 - James Cash / @jamesnvc

01/28/2011 at 07:45AM

Default_profile_1_normal
58
#52 - Alekseyka2 / @Alekseyka2

01/28/2011 at 02:30PM

Bauchi_mask_normal
58
#53 - Mark Smith-Guerrero / @msmithgu

02/01/2011 at 10:06AM

O78a2ujeqbyrqkgsuto8_normal
58
#54 - Alex Hammel / @AlexJHammel

12/23/2012 at 07:05AM

1309650785306_normal
59
#55 - Rob Ciaccio / @RobertoCalavera

01/28/2011 at 10:16AM

Bender_normal
59
#56 - Daniel / @dpaneda

09/26/2011 at 03:47PM

Me_glam_face1_normal
59
#57 - banana / @sparkleseed

03/13/2012 at 08:37AM

Default_profile_1_normal
62
#58 - Rörd Hinrichsen / @roerdhh

01/28/2011 at 07:03PM

Default_profile_5_normal
62
#59 - Nomen Nescio / @vadtusan

04/14/2011 at 01:03AM

Avatar_normal
63
#60 - Federico Bond / @federicobond

09/22/2012 at 04:15PM

Default_profile_4_normal
64
#61 - Burkhard Zimmermann / @BurkZimm

12/26/2011 at 03:35PM

187559_1578484375_479499_n_normal
65
#62 - Steven Occhipinti / @steveocchipinti

02/02/2011 at 07:27PM

Default_profile_1_normal
65
#63 - Dj Vimgolf / @dj_vimgolf

12/30/2011 at 05:16PM

Hello_badge_normal
66
#64 - Matthieu Honel / @ocus

01/28/2011 at 07:31AM

Aquarium_and_atlanta_buildings_098_-_copy_normal
67
#65 - Helder Inacio / @inaciohj

02/02/2011 at 07:32PM

Bear_normal
67
#66 - Torben Rasmussen / @rasmustorben

08/16/2011 at 09:34AM

Profile_m_normal
69
#67 - Dmitry Teslenko / @krab_mozga

02/02/2011 at 01:43AM

Twitterprofilephoto_normal
70
#68 - Jon Bettinger / @jonbettinger

01/30/2011 at 06:35PM

Default_profile_3_normal
70
#69 - stefan otte / @stefanotte

01/30/2012 at 05:39AM

Dhpe-twitter_normal
70
#70 - Arto Vuori / @dhpe

09/01/2012 at 09:50AM

Vernon_normal
72
#71 - Vernon Thommeret / @synotic

01/30/2011 at 07:38AM

Image1326661166_normal
72
#72 - Christopher Brew / @Seph1rothVII

01/10/2012 at 04:41PM

L3mo9g2d3jpj7ysqb4iz_normal
73
#73 - Pasha Klets / @p01nt

01/28/2011 at 07:27AM

Tektek_avatar_closeup_normal
75
#74 - Franco Lazzarino / @flazz

01/28/2011 at 04:51PM

Default_profile_0_normal
75
#75 - grizzancs / @grizzancs

01/31/2011 at 04:13AM

Image_normal
79
#76 - Solomon White / @rubysolo

01/28/2011 at 08:58AM

Mugshot_normal
104
#77 - Reza Lotun / @rlotun

01/30/2011 at 10:32AM

2262419520_e5832a812d_normal
141
#78 - Ilya Grigorik / @igrigorik

01/31/2011 at 04:43PM

Me_normal
146
#79 - David Burns / @AutomatedTester

01/28/2011 at 07:17AM