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


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

59 active golfers, 211 entries

Leaderboard (lowest score wins):
120
#31 - Renat Aksitov / @Korvin79

01/29/2012 at 12:04PM

120
#32 - mwatkward / @AftrschoolSpe

06/25/2012 at 10:06PM

121
#33 - Asmund / @herrasbe

01/04/2011 at 10:20PM

121
#34 - aimee / @sermoa

01/08/2011 at 04:37PM

122
#35 - Mighty Byte / @mightybyte

01/10/2011 at 10:30PM

122
#36 - Colin Benner / @yzhs

01/12/2025 at 05:32PM

123
#37 - timhoa / @timhoa

01/23/2011 at 03:36PM

123
#38 - shahanavaz m / @shahanavazm

03/07/2024 at 10:45PM

125
#39 - Ayose Cazorla / @ayosec

09/03/2011 at 03:37PM

127
#40 - Mohammad-Javad Izadi / @mjizadi

01/05/2011 at 12:56PM

127
#41 - Rob Ciaccio / @RobertoCalavera

01/27/2011 at 12:00AM

129
#42 -  Ikhsan Maulana / @ixandidu

01/07/2011 at 07:29PM

132
#43 - Eivind Jahren / @HaskellElephant

01/18/2011 at 11:03PM

133
#44 - not so punk :] / @notsopunk

06/19/2011 at 10:18AM

134
#45 - Piotr Śniegowski / @PiotrSniegowski

06/06/2013 at 01:50PM

136
#46 - Francisco Dibar / @frandibar

01/13/2011 at 08:10PM

138
#47 - drio / @drio

01/16/2011 at 10:24PM

142
#48 - Mattiassich Ákos / @mattiassicha

01/04/2011 at 08:20PM

143
#49 - Alain Gilbert / @alain_gilbert

01/05/2011 at 08:58PM

144
#50 - Vernon Thommeret / @synotic

01/30/2011 at 07:54AM

148
#51 - Pete Johns / @johnsyweb

01/04/2011 at 08:16PM

157
#52 - sylwia / @whaler

09/12/2011 at 05:45PM

158
#53 - Christopher Brew / @Seph1rothVII

01/12/2012 at 07:49PM

160
#54 - Daniel Harrington / @rubiii

12/11/2011 at 01:24AM

190
#55 - Pieter-Jan Lavaerts / @Pumpkin_Pie_Eat

03/08/2024 at 04:00PM

248
#56 - Joost / @vlabakje

02/21/2011 at 04:53PM

348
#57 - Marcelo F Andrade / @mfandrade

01/04/2011 at 07:34PM

354
#58 - Mukhanov / @Mukhanov

02/03/2014 at 08:04AM

354
#59 - nickGPT / @nickandbro

08/28/2024 at 11:22PM