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

109 active golfers, 333 entries

Leaderboard (lowest score wins):
55
#61 - Chris Penkett / @chrispenkett

04/03/2012 at 06:57PM

55
#62 - James / @Dronak

09/20/2014 at 05:54PM

55
#63 - Marcus Loo / @MarcusLoo1

09/19/2019 at 06:28PM

56
#64 - Matti Hänninen / @mjhanninen

01/30/2011 at 09:35PM

56
#65 - Ian McCowan / @valrus

05/29/2011 at 08:34PM

56
#66 - Dave / @zzdave13

07/18/2011 at 09:29PM

56
#67 - Ayose Cazorla / @ayosec

09/03/2011 at 04:03PM

56
#68 - Kyle X. Clark / @KyXr_Clark

02/10/2020 at 03:25AM

57
#69 - Amy / @imightbeAmy

02/15/2013 at 05:47PM

57
#70 - Richard Davison / @richarddavison

07/14/2017 at 05:28PM

57
#71 - shahanavaz m / @shahanavazm

02/20/2022 at 02:35AM

58
#72 - James Cash / @jamesnvc

01/28/2011 at 03:45PM

58
#73 - Alekseyka2 / @Alekseyka2

01/28/2011 at 10:30PM

58
#74 - Mark Smith-Guerrero / @msmithgu

02/01/2011 at 06:06PM

58
#75 - ajh / @AlexJHammel

12/23/2012 at 03:05PM

59
#76 - Rob Ciaccio / @RobertoCalavera

01/28/2011 at 06:16PM

59
#77 - Daniel / @dpaneda

09/26/2011 at 10:47PM

59
#78 - banana / @sparkleseed

03/13/2012 at 03:37PM

59
#79 - Munzor / @t3hmun

04/28/2014 at 06:38PM

60
#80 - Michael Perrone / @ThePerrone

12/22/2013 at 03:28AM

60
#81 - Daniel Jonsson / @DanielJonss

01/21/2014 at 04:47PM

60
#82 - かしゅーなっつ@修行中 / @kashew_nuts

08/02/2014 at 08:38AM

62
#83 - Rörd Hinrichsen / @roerdhh

01/29/2011 at 03:03AM

62
#84 - Nomen Nescio / @vadtusan

04/14/2011 at 08:03AM

62
#85 - Torikatsu / @torikatsu923

02/12/2021 at 06:34PM

63
#86 - Federico Bond / @federicobond

09/22/2012 at 11:15PM

63
#87 - Gurukandhamoorthi / @Gurukandhamoor1

09/02/2017 at 05:03PM

64
#88 - Burkhard Zimmermann / @BurkZimm

12/26/2011 at 11:35PM

65
#89 - Steven Occhipinti / @steveocchipinti

02/03/2011 at 03:27AM

65
#90 - Dj Vimgolf / @dj_vimgolf

12/31/2011 at 01:16AM