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 35 remaining solutions by signing in and submitting your own entry
#36 Goonoo Kim / mctenshi - Score: 35 - 01/09/16 @ 15:07
28Gddk<C-V>kldkddjpi  only_<Right><Right> {<Esc>$a }<Esc>ZZ

0 comments

#37 Dinesh Bhosale / MrDineshBhosale - Score: 35 - 04/01/16 @ 22:08
24jdd<Down>pi  only_<Right><Right> {<End> }<Down><Esc>dd<Up><Up><Del><Del><Up><Del><Del>ZZ

0 comments

#38 Mikael Saltzman / MikaelSaltzman - Score: 37 - 12/28/15 @ 23:02
28Gddk<C-V>klxkionly_<Esc>wi{ <Esc>A }<Esc>ddjpi  <Esc>ZZ

0 comments

#39 Marcel Akkerman / MarcelAkkerman - Score: 37 - 12/22/16 @ 14:39
28Gddk<C-V>lkdkddjoonly_<Esc>pkgJf i {<Esc>A }<Esc>ZZ

0 comments

#40 Gurukandhamoorthi / Gurukandhamoor1 - Score: 37 - 07/24/17 @ 16:14
25Gddjoonly_<C-R>"<C-O>2dd<Up><End> }<Esc>Fni{ <Esc>0<C-V>kklxZZ

0 comments

#41 twenty2twoss / twenty2twoss - Score: 38 - 01/14/16 @ 18:31
28Gddk<C-V>kldkddjpi  only_<Right><Right> {<Esc>A }ZZ<BS><BS><Esc>ZZ

0 comments

#42 Campbell Davis / Campbell_Dav - Score: 40 - 12/17/15 @ 07:43
25Gionly_<Esc>ddpwi{ <Esc>$a }<Esc>0i  <Esc>j2xjdd3kdwZZ

0 comments

#43 Andy Loomis / alumux - Score: 41 - 12/23/15 @ 11:59
25Gionly_<Esc>wi{ <Esc>A }<Esc>+hh<C-V>jjlxkddjpi  <Esc>jddZZ

0 comments

#44 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

44 active golfers, 136 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

26
#3 - Urtica dioica / udioica

12/15/2015 at 05:15PM

26
#4 - John Braxler / braxler

12/15/2015 at 05:36PM

26
#5 - Alan Kang / alankang

01/08/2016 at 02:13PM

26
#6 - DrHobo / _DrHobo_

01/11/2016 at 09:44PM

26
#7 - jackliusr / jackliusr

01/12/2016 at 07:21AM

26
#8 - ben kavanagh / bkava

02/23/2016 at 05:27PM

26
#9 - Dimitar Dimitrov / kurkale6ka

03/14/2016 at 03:12PM

26
#10 - Bill Ruddock / biinari

10/25/2016 at 02:42PM

26
#11 - Nick Spoon / be_the_spoon

03/07/2017 at 10:35PM

27
#12 - Smylers / Smylers2

12/16/2015 at 09:47AM

28
#13 - adrien frediani / fredianiadrien

12/15/2015 at 10:25PM

28
#14 - Matthieu Crapet / mcr05

01/02/2016 at 09:38AM

28
#15 - retro / tryphopp

01/14/2016 at 03:57AM

29
#16 - Jan Path / jan_path

12/17/2015 at 03:14PM

29
#17 - Sergey Fedorov / Shade30

01/13/2016 at 08:49AM

29
#18 - Frederik Klama / fklama

01/27/2016 at 12:19PM

29
#19 - Fraser Cormack / frasercrmck

03/25/2016 at 06:53PM

30
#20 - Paulo H Baumann / PauloBaumann

12/18/2015 at 03:27PM

30
#21 - Cristian Lupașcu / clupasq

02/25/2016 at 08:33PM

30
#22 - John Smith / literacyisgood

03/04/2016 at 08:01PM

30
#23 - Carlos A Henríquez Q / lagunex

03/13/2016 at 03:34PM

31
#24 - Jon Krause / jkrause314

12/15/2015 at 06:36PM

31
#25 - mnx / mnxx

12/17/2015 at 01:30PM

32
#26 - najeem / najeem

12/16/2015 at 07:29PM

32
#27 - Ashley Feniello / AshleyFen

12/17/2015 at 11:28PM

33
#28 - Michael Donux / foodtooth

12/16/2015 at 02:42AM

33
#29 - Walker Boh / walker_boh

12/16/2015 at 08:00AM

33
#30 - Daniel / Daniel00288663

03/31/2017 at 02:02PM

34
#31 - Jason Schulz / uxcn_

12/15/2015 at 07:49PM

34
#32 - h l / lonnez90

12/16/2015 at 10:39PM

34
#33 - Aaron Mininger / AMininger

12/24/2015 at 06:08PM

35
#34 - Brian D. Goad / bbbco

12/15/2015 at 05:16PM

35
#35 - macmental / macmental

12/18/2015 at 10:35PM

35
#36 - Goonoo Kim / mctenshi

01/09/2016 at 03:07PM

35
#37 - Dinesh Bhosale / MrDineshBhosale

04/01/2016 at 10:08PM

37
#38 - Mikael Saltzman / MikaelSaltzman

12/28/2015 at 11:02PM

37
#39 - Marcel Akkerman / MarcelAkkerman

12/22/2016 at 02:39PM

37
#40 - Gurukandhamoorthi / Gurukandhamoor1

07/24/2017 at 04:14PM

38
#41 - twenty2twoss / twenty2twoss

01/14/2016 at 06:31PM

40
#42 - Campbell Davis / Campbell_Dav

12/17/2015 at 07:43AM

41
#43 - Andy Loomis / alumux

12/23/2015 at 11:59AM

53
#44 - Jakob Schöttl / jschoettl

12/20/2015 at 12:24AM