- Go to 'Tools' -> 'New Snippet'
- Replace the default content with the below
<snippet> <content><![CDATA[ public ${1:returnType} get${2:Property}(){ return ${3:property}; } public void set${2:Property}(${1:returnType} ${3:property}){ this.${3:property} = ${3:property}; } ]]></content> <tabTrigger>gs</tabTrigger> </snippet>
- Save the file in sublime-text-2/Packages/User/urfilename.sublime-snippet
- Open the java file that needs getter and setter methods
- Type "gs" and hit 'tab'
- Snippet should be created at this point and returnType should be highlighted. Type in the returnType of the property for which these getter and setters are being created
- Hit 'tab'. Property will be highlighted. Type in the property name with first letter in uppercase.
- Hit 'tab'. type in the property name as it is
Saturday, April 28, 2012
Sublime snippet for creating getter and setter methods in Java class.
Subscribe to:
Posts (Atom)