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

53 active golfers, 181 entries

Leaderboard (lowest score wins):
25
#1 - Saki Gw / @Sakigw

01/06/2016 at 11:04PM

25
#2 - Aleksey Zhidkov / @AlexeyZhidkov

01/27/2016 at 10:47AM

25
#3 - Turkey Man / @lvturkeyman

11/26/2017 at 03:29PM

25
#4 - DHM / @DHM29978992

05/20/2018 at 12:36AM

25
#5 - Mihai / @mihaicristiant

03/26/2019 at 12:36PM

25
#6 - Arya Kumar / @SusSquirrel

05/24/2021 at 11:37PM

25
#7 - Jean George / @JeanGeo20504212

05/22/2022 at 09:37PM

25
#8 - Peppa Pig / @PeppaPigSg

07/03/2024 at 01:05AM

26
#9 - Urtica dioica / @udioica

12/15/2015 at 05:15PM

26
#10 - John Braxler / @braxler

12/15/2015 at 05:36PM

26
#11 - Alan Kang / @alankang

01/08/2016 at 02:13PM

26
#12 - DrHobo / @_DrHobo_

01/11/2016 at 09:44PM

26
#13 - jackliusr / @jackliusr

01/12/2016 at 07:21AM

26
#14 - ben kavanagh / @bkava

02/23/2016 at 05:27PM

26
#15 - Dimitar Dimitrov / @kurkale6ka

03/14/2016 at 03:12PM

26
#16 - Bill Ruddock / @biinari

10/25/2016 at 02:42PM

26
#17 - Nick Spoon / @be_the_spoon

03/07/2017 at 10:35PM

27
#18 - "Smylers" / @Smylers2

12/16/2015 at 09:47AM

28
#19 - adrien frediani / @fredianiadrien

12/15/2015 at 10:25PM

28
#20 - Matt / @mcr05

01/02/2016 at 09:38AM

28
#21 - retro / @tryphopp

01/14/2016 at 03:57AM

29
#22 - Jan Path / @jan_path

12/17/2015 at 03:14PM

29
#23 - Sergey Fedorov / @Shade30

01/13/2016 at 08:49AM

29
#24 - Frederik Klama / @fklama

01/27/2016 at 12:19PM

29
#25 - Fraser Cormack / @frasercrmck

03/25/2016 at 06:53PM

30
#26 - Paulo H Baumann / @PauloBaumann

12/18/2015 at 03:27PM

30
#27 - Cristian Lupașcu / @clupasq

02/25/2016 at 08:33PM

30
#28 - John Smith / @literacyisgood

03/04/2016 at 08:01PM

30
#29 - Carlos A Henríquez Q / @lagunex

03/13/2016 at 03:34PM

31
#30 - Jon Krause / @jkrause314

12/15/2015 at 06:36PM