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 5f316d5c8d826b000640670e

C to python code snippet

C code can be easily translated into Python code. However, the difference in syntax can make this process tedious and time-consuming. Can Vim help you here?

Start file
const wc_units_data wc_units_frequency[]=
{
    {"mHz", 1e-3},
    {"Hz", 1.0},
    {"kHz", 1e3},
    {"MHz", 1e6},
    {"GHz", 1e9},
    {NULL,0}
};
End file
def wc_units_frequency():
    return {"mHz": 1e-3,
            "Hz": 1.0,
            "kHz": 1e3,
            "MHz": 1e6,
            "GHz": 1e9,
            "NULL": 0}

View Diff

1,9c1,7
< const wc_units_data wc_units_frequency[]=
< {
<     {"mHz", 1e-3},
<     {"Hz", 1.0},
<     {"kHz", 1e3},
<     {"MHz", 1e6},
<     {"GHz", 1e9},
<     {NULL,0}
< };
---
> def wc_units_frequency():
>     return {"mHz": 1e-3,
>             "Hz": 1.0,
>             "kHz": 1e3,
>             "MHz": 1e6,
>             "GHz": 1e9,
>             "NULL": 0}

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 11 remaining solutions by signing in and submitting your own entry
#12 Borna Sadeghi / @borna_sadeghi - Score: 108 - 04/03/21 @ 15:43
c2t def<Esc>f[c$():<Esc>:%s/\v[[\<BS><BS><BS>[\{\},;]//g<CR>ddi"<Esc>f0i": <Esc>A}<Esc>qqkA,<Esc>F"a:<Esc>q4@qki    return {<Esc>Jxf<C-C><C-C>j0<C-V>k5jI        <Esc>ZZ

0 comments


Created by: @Seve_py

12 active golfers, 38 entries

Leaderboard (lowest score wins):
48
#1 - Tom Dalling / @tom_dalling

08/31/2020 at 02:36AM

49
#2 - Saki Gw / @Sakigw

08/12/2020 at 11:42AM

49
#3 - Jon Krause / @jkrause314

08/12/2020 at 01:45PM

49
#4 - Tanzeel Kazi / @tanzeelkazi

08/12/2020 at 10:50PM

53
#5 - Martin Bielik / @mabielik

08/11/2020 at 08:56PM

53
#6 - Andreas Siegrist / @andreaszwei

06/16/2021 at 05:59PM

58
#7 - Seve / @Seve_py

08/11/2020 at 08:53AM

68
#8 - RockerZZY / @rocker_zzy

08/24/2020 at 09:55AM

76
#9 - A White Dwarf / @AWhiteDwarf1

07/02/2021 at 04:18PM

77
#10 - Martin Kauppinen / @MartinKauppinen

08/15/2020 at 12:22PM

102
#11 - Sergio / @SergioVl12

08/15/2020 at 05:07AM

108
#12 - Borna Sadeghi / @borna_sadeghi

04/03/2021 at 03:43PM