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 56eb0843251cf25ae40963de

underscore_to_camelCase

Pointy haired boss decided we need to switch to camelCase. Let's get this over with.

Start file
log(req, res, next) {
    try {
        let ratio = this.config.get("HEADER_LOG_FREQ", 0.05);
        if (Math.random() < ratio) {
            this.arrange_headers(req, res).then(this.write_log);
        }
        let safe_path = this.safe_graphite_path(req.path);
        this.stats.increment("web.endpoint." + safe_path, 1, 0.05);
        if (req.headers && req.headers["x-forwarded-proto"]) {
            this.stats.increment("web.protocol." + req.headers["x-forwarded-proto"], 1, 0.05);
        }
    } catch (error) {
        log.warning(error, "Failed to log headers");
        res.status(500).send("its_not_you_its_me");
    } finally {
        next();
    }
}
End file
log(req, res, next) {
    try {
        let ratio = this.config.get("HEADER_LOG_FREQ", 0.05);
        if (Math.random() < ratio) {
            this.arrangeHeaders(req, res).then(this.writeLog);
        }
        let safePath = this.safeGraphitePath(req.path);
        this.stats.increment("web.endpoint." + safePath, 1, 0.05);
        if (req.headers && req.headers["x-forwarded-proto"]) {
            this.stats.increment("web.protocol." + req.headers["x-forwarded-proto"], 1, 0.05);
        }
    } catch (error) {
        log.warning(error, "Failed to log headers");
        res.status(500).send("its_not_you_its_me");
    } finally {
        next();
    }
}

View Diff

5c5
<             this.arrange_headers(req, res).then(this.write_log);
---
>             this.arrangeHeaders(req, res).then(this.writeLog);
7,8c7,8
<         let safe_path = this.safe_graphite_path(req.path);
<         this.stats.increment("web.endpoint." + safe_path, 1, 0.05);
---
>         let safePath = this.safeGraphitePath(req.path);
>         this.stats.increment("web.endpoint." + safePath, 1, 0.05);

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 72 remaining solutions by signing in and submitting your own entry
#73 Sebastian Pfluegelm / @sebastian_pflgl - Score: 35 - 06/04/16 @ 22:31
/_n<BS><CR>nnxrHnxRL<Esc>nxrPnxrGnxrPnxrP:wq<CR>

0 comments


Created by: @assaflavie

73 active golfers, 145 entries

Leaderboard (lowest score wins):
21
#61 - we’re going to need a bigger bot / @assaflavie

03/17/2016 at 07:47PM

21
#62 - basilest / @basilest

03/18/2016 at 12:04AM

21
#63 - Gurukandhamoorthi / @Gurukandhamoor1

07/20/2017 at 03:26PM

22
#64 - matt_todd / @matt_todd

04/15/2016 at 11:39PM

22
#65 - Jan Balangue / @jbalang

01/05/2020 at 09:51PM

23
#66 - Michael Prouty / @MProuts

03/20/2016 at 05:22PM

24
#67 - Christian Rondeau / @c_rondeau

10/18/2016 at 01:58AM

24
#68 - Marcel Akkerman / @MarcelAkkerman

12/22/2016 at 12:27PM

25
#69 - Alexander Pivovarov / @pivizz

03/19/2016 at 07:35PM

25
#70 - tapio / @gncnaxb

02/16/2018 at 12:35PM

26
#71 - Kevin Ilphrin Pellet / @Kilphrin

03/17/2016 at 09:33PM

26
#72 - Bruce Park / @bpark0

03/21/2016 at 12:22AM

35
#73 - Sebastian Pfluegelm / @sebastian_pflgl

06/04/2016 at 10:31PM