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 56704157109fb85a6d017d08

FoodCritic023: Prefer conditional attributes

FoodCritic (www.foodcritic.io) is a lint tool for your Chef (learn.chef.io) cookbooks. FC023 indicates that you should prefer Chef guards over Ruby conditions. This challenge expects you to be able to fix this issue in a sample cookbook, given the FoodCritic output: ================================================================ FC023: Prefer conditional attributes: cookbooks/foo/recipes/default.rb:25 ================================================================ See http://www.foodcritic.io/#FC023 for more details about the changes being made.

Start file
# Cookbook Name:: foo
# Recipe:: default
#
# Copyright 2015, Foo Inc.
#
# All rights reserved - Do Not Redistribute
#

directory "/opt/foo" do
end

remote_file "/tmp/foo.rpm" do
  source "http://foo.inc/packages/foo.rpm"
  action :create
end

rpm_package "/tmp/foo.rpm" do
  action :install
end

service "foo" do
  action :start
end

if node["foo"] == "bar"
  execute "bar my foo" do
    command "foo < bar"
  end
end
End file
# Cookbook Name:: foo
# Recipe:: default
#
# Copyright 2015, Foo Inc.
#
# All rights reserved - Do Not Redistribute
#

directory "/opt/foo" do
end

remote_file "/tmp/foo.rpm" do
  source "http://foo.inc/packages/foo.rpm"
  action :create
end

rpm_package "/tmp/foo.rpm" do
  action :install
end

service "foo" do
  action :start
end

execute "bar my foo" do
  command "foo < bar"
  only_if { node["foo"] == "bar" }
end

View Diff

25,28c25,27
< if node["foo"] == "bar"
<   execute "bar my foo" do
<     command "foo < bar"
<   end
---
> execute "bar my foo" do
>   command "foo < bar"
>   only_if { node["foo"] == "bar" }

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 46 remaining solutions by signing in and submitting your own entry
#47 Jakob Schöttl / @jschoettl - Score: 53 - 12/20/15 @ 00:24
/if<CR>dw"aDddjoonly_if { <Esc>pu"apA }<Esc>jjddb0<C-V>j<Esc><Esc><C-V>kkkld:wq<CR>

0 comments


Created by: @bbbco

47 active golfers, 161 entries

Leaderboard (lowest score wins):
33
#31 - Michael Donux / @foodtooth

12/16/2015 at 02:42AM

33
#32 - Walker Boh / @walker_boh

12/16/2015 at 08:00AM

33
#33 - Daniel / @Daniel00288663

03/31/2017 at 02:02PM

34
#34 - Jason Schulz / @uxcn_

12/15/2015 at 07:49PM

34
#35 - Holden Lewis / @lonnez90

12/16/2015 at 10:39PM

34
#36 - Aaron Mininger / @AMininger

12/24/2015 at 06:08PM

35
#37 - Brian D. Goad / @bbbco

12/15/2015 at 05:16PM

35
#38 - macmental / @macmental

12/18/2015 at 10:35PM

35
#39 - Goonoo Kim / @mctenshi

01/09/2016 at 03:07PM

35
#40 - Dinesh Bhosale / @MrDineshBhosale

04/01/2016 at 10:08PM

37
#41 - Mikael Saltzman / @MikaelSaltzman

12/28/2015 at 11:02PM

37
#42 - Marcel Akkerman / @MarcelAkkerman

12/22/2016 at 02:39PM

37
#43 - Gurukandhamoorthi / @Gurukandhamoor1

07/24/2017 at 04:14PM

38
#44 - twenty2twoss / @twenty2twoss

01/14/2016 at 06:31PM

40
#45 - Campbell Davis / @Campbell_Dav

12/17/2015 at 07:43AM

41
#46 - Andy Loomis / @alumux

12/23/2015 at 11:59AM

53
#47 - Jakob Schöttl / @jschoettl

12/20/2015 at 12:24AM