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 @g_mawr:

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

32 active golfers, 86 entries

Solutions by @g_mawr:
103
#3 - Geraint Hywel / @g_mawr

03/01/2014 at 08:58PM

106
#>3 - Geraint Hywel / @g_mawr

03/01/2014 at 08:47PM

107
#>3 - Geraint Hywel / @g_mawr

03/01/2014 at 08:41PM

108
#>4 - Geraint Hywel / @g_mawr

03/01/2014 at 08:39PM

110
#>4 - Geraint Hywel / @g_mawr

03/01/2014 at 07:42PM

111
#>5 - Geraint Hywel / @g_mawr

02/28/2014 at 10:37PM

112
#>5 - Geraint Hywel / @g_mawr

02/28/2014 at 10:06PM

113
#>5 - Geraint Hywel / @g_mawr

02/28/2014 at 10:03PM

118
#>7 - Geraint Hywel / @g_mawr

02/28/2014 at 09:39PM

120
#>8 - Geraint Hywel / @g_mawr

02/27/2014 at 11:53PM

121
#>8 - Geraint Hywel / @g_mawr

02/27/2014 at 11:38PM

122
#>8 - Geraint Hywel / @g_mawr

02/27/2014 at 12:35AM

123
#>10 - Geraint Hywel / @g_mawr

02/27/2014 at 12:20AM

124
#>11 - Geraint Hywel / @g_mawr

02/27/2014 at 12:15AM

126
#>12 - Geraint Hywel / @g_mawr

02/27/2014 at 12:07AM

131
#>14 - Geraint Hywel / @g_mawr

02/26/2014 at 11:39PM