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 4d22dcfa7f75b01e0700010e

Getters & Setters: Java

Boilerplate getters & setters - it's a tedious fact of life in Java, and probably the only thing that still pulls me back to an IDE. Perhaps someone knows a fast, pure vim way...

Start file
package com.vimgolf.challenge;

public class Person {
	private String firstName;
	private String surname;
	private Integer age;
}
End file
package com.vimgolf.challenge;

public class Person {
	private String firstName;
	private String surname;
	private Integer age;

	public String getFirstName() { return firstName; }
	public void setFirstName( String firstName ) {
		this.firstName = firstName;
	}

	public String getSurname() { return surname; }
	public void setSurname( String surname ) {
		this.surname = surname;
	}

	public Integer getAge() { return age; }
	public void setAge( Integer age ) {
		this.age = age;
	}
}

View Diff

6a7,21
> 
> 	public String getFirstName() { return firstName; }
> 	public void setFirstName( String firstName ) {
> 		this.firstName = firstName;
> 	}
> 
> 	public String getSurname() { return surname; }
> 	public void setSurname( String surname ) {
> 		this.surname = surname;
> 	}
> 
> 	public Integer getAge() { return age; }
> 	public void setAge( Integer age ) {
> 		this.age = age;
> 	}

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 56 remaining solutions by signing in and submitting your own entry
#57 Mukhanov / @Mukhanov - Score: 354 - 02/03/14 @ 08:04
3jyy3jO<CR><Tab><Esc>pkddcwpyb<BS><BS>ublic<Esc>wwiget<Esc>kjlrFA<BS>() { return firstName; }<CR><Esc>kyyjkpwcwviud<BS><BS>d<BS>od<BS><BS><BS>oid<Esc>wrswwwcwStri<BS><BS><BS><BS><Left><Left><Left><Left>S<BS> String firstName <Esc>llla<CR><Tab>i<BS>this.<Esc>A<Left><Left><Left>u<BS> = fri<BS><BS>is<BS>rstName<Esc>kjla<CR><BS><Esc>3k4yy3jjpffbbbblllcwSy<BS>urba<BS><BS>bane<BS><BS><BS><BS>name<Esc>wwwwcwsurbae<BS><BS><BS>name<Esc>hjb.jb.bbb.kbkhjllllcwSurbam<BS><BS><BS>name<Esc>k4yyjjjpO<Esc>jwcwInteger<Esc>jww.jkkbbblllcwAge<Esc>wwwwcwage<Esc>jhhh.jv<Esc>b.bbb.kcwAge<Esc>:wq<CR>

0 comments


#58 nickGPT / @nickandbro - Score: 354 - 08/28/24 @ 23:22
3jyy3jO<CR><Tab><Esc>pkddcwpyb<BS><BS>ublic<Esc>wwiget<Esc>kjlrFA<BS>() { return firstName; }<CR><Esc>kyyjkpwcwviud<BS><BS>d<BS>od<BS><BS><BS>oid<Esc>wrswwwcwStri<BS><BS><BS><BS><Left><Left><Left><Left>S<BS> String firstName <Esc>llla<CR><Tab>i<BS>this.<Esc>A<Left><Left><Left>u<BS> = fri<BS><BS>is<BS>rstName<Esc>kjla<CR><BS><Esc>3k4yy3jjpffbbbblllcwSy<BS>urba<BS><BS>bane<BS><BS><BS><BS>name<Esc>wwwwcwsurbae<BS><BS><BS>name<Esc>hjb.jb.bbb.kbkhjllllcwSurbam<BS><BS><BS>name<Esc>k4yyjjjpO<Esc>jwcwInteger<Esc>jww.jkkbbblllcwAge<Esc>wwwwcwage<Esc>jhhh.jv<Esc>b.bbb.kcwAge<Esc>:wq<CR>

0 comments


Created by: @krisajenkins

58 active golfers, 207 entries

Leaderboard (lowest score wins):
89
#1 - Petro Тrouq / @zulolosi

01/03/2015 at 02:10PM

89
#2 - kok / @kok89428331

07/25/2020 at 03:01PM

89
#3 - Peppa Pig / @PeppaPi95550250

07/03/2024 at 08:39AM

91
#4 - Urtica dioica / @udioica

01/30/2013 at 01:08AM

91
#5 - John Braxler / @braxler

12/22/2014 at 07:19PM

91
#6 - vimgolfer / @vimgolfer7

10/06/2019 at 03:16AM

92
#7 - Wei Dai / @clvv42

01/07/2011 at 02:21AM

92
#8 - ls lahrs / @lslah

01/17/2011 at 04:35PM

92
#9 - You-Siang Lin / @yslinnctu

12/05/2011 at 01:57PM

94
#10 - dominique pellé / @vimgolfisto

01/05/2011 at 12:33AM

95
#11 - Nolen Royalty / @NolenRoyalty

04/21/2012 at 09:43PM

96
#12 - Justin Love / @wondible

08/17/2011 at 02:44AM

97
#13 - BnnGolfer / @BnnGolfer

03/21/2020 at 06:53PM

98
#14 - Saki Gw / @Sakigw

06/18/2016 at 05:23PM

98
#15 - Paul Molloy / @paulsmolloy

11/22/2023 at 10:08PM

99
#16 - William Dunand / @wdunand

11/17/2011 at 07:25AM

100
#17 - h_east (トロッコ6個) / @h_east

01/04/2011 at 03:32PM

105
#18 - Matthew Draper / @_matthewd

01/06/2011 at 05:44AM

106
#19 - Karel Vervaeke / @karel1980

01/04/2011 at 02:12PM

106
#20 - Joonas Pihlajamaa / @jokkebk

02/23/2014 at 09:02PM

108
#21 - Hu Junfeng / @junfeng

07/27/2011 at 12:51PM

109
#22 - Douglas Stockwell / @dstockwell

01/05/2011 at 02:21AM

110
#23 - hiding / @I_haveno_name

11/14/2013 at 12:31AM

111
#24 - Tim Chase / @gumnos

01/04/2011 at 11:19PM

112
#25 - Gael / @darkael2

01/06/2011 at 07:18PM

113
#26 - Øystein Walle / @oysteinwalle

07/08/2011 at 11:08PM

113
#27 - galadriel2143 / @galadriel2143

07/05/2013 at 05:13AM

114
#28 - Glenn / @spamcow_moo

01/04/2011 at 07:00PM

115
#29 - RockerZZY / @rocker_zzy

08/30/2020 at 12:14PM

119
#30 - Mateen Ulhaq / @sicariusnoctis

02/12/2019 at 10:10AM