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 530d2148f78def0002660c96

Write Setters and Getters for PHP

Just simple automation of writing Setters and Getters like Doctrine might use.

Start file
<?php
class Example {

	firstProperty
	secondItem
	lastAttribute
}
End file
<?php
class Example {

	private $firstProperty;

	public function getFirstProperty()
	{
		return $this->firstProperty;
	}

	public function setFirstProperty($value)
	{
		$this->firstProperty = $value;
	}

	private $secondItem;

	public function getSecondItem()
	{
		return $this->secondItem;
	}

	public function setSecondItem($value)
	{
		$this->secondItem = $value;
	}

	private $lastAttribute;

	public function getLastAttribute()
	{
		return $this->lastAttribute;
	}

	public function setLastAttribute($value)
	{
		$this->lastAttribute = $value;
	}
}

View Diff

4,6c4,38
< 	firstProperty
< 	secondItem
< 	lastAttribute
---
> 	private $firstProperty;
> 
> 	public function getFirstProperty()
> 	{
> 		return $this->firstProperty;
> 	}
> 
> 	public function setFirstProperty($value)
> 	{
> 		$this->firstProperty = $value;
> 	}
> 
> 	private $secondItem;
> 
> 	public function getSecondItem()
> 	{
> 		return $this->secondItem;
> 	}
> 
> 	public function setSecondItem($value)
> 	{
> 		$this->secondItem = $value;
> 	}
> 
> 	private $lastAttribute;
> 
> 	public function getLastAttribute()
> 	{
> 		return $this->lastAttribute;
> 	}
> 
> 	public function setLastAttribute($value)
> 	{
> 		$this->lastAttribute = $value;
> 	}

Solutions by @only4vimgolf:

Unlock 2 remaining solutions by signing in and submitting your own entry
Created by: @khamer

32 active golfers, 86 entries

Solutions by @only4vimgolf:
149
#21 - kAworu / @only4vimgolf

03/12/2014 at 02:30PM

166
#>28 - kAworu / @only4vimgolf

03/12/2014 at 02:20PM