Eclipse IDE provides a one of finest tip for all Developer
to make their coding easy and make their life easy.
In this post we will try to understand “surround with”
option, in this option mainly we focus on customizing the template with
respective code.
Direction towards
surround with
When we right click on selected code we will get an option
called surround with there we will find following options.
Try /catch Block
- do (do while statement)
- for (iterate over array )
- if (if statement)
- runnable (runnable)
- synchronized (synchronized block)
- try (try catch block)
- while (while loop with condition)
Configure templates .. // we will see in second part
I hope every one of us knows more details about these
feature but we will try to see how it looks when we select each of them.
Try / catch Block.
Once we select try/catch option whole selected code will be
under try catch block let see next image.
Similarly all other options will be implemented except last
option configure templates.
Lets now focus towards configuring custom template.
We can select option without selecting any code but we
simple shortcut select windows>> preference>>Java >> Editor
>> Templates
Here is the following image
Now we will see one of the default template, I mostly use
main as one of shortcut once type main and press Ctrl + Space to show the template proposal
please check below image.
So here are few examples for default template names
// main Ctrl+Spaces
gives public static void main (String args[]) {}
// sysout Ctrl+Spaces
gives System.out.println();
// syserr Ctrl+Spaces gives System.err.println()
//lazy Ctrl+Spaces gives if (args == null) { args = new
type(arguments); } return args;
Now we will drive with some internal of adding templates.
Steps
- Press Windows >> Preference >> Java >> Editor >> Templates
- It will open the Template wizard and now press New for more check below image
- Provide some template name shortcut name under Name
- Select any one of the context type they are
- Java
- Java statements
- Java type members
- Javadoc
- SWT
- SWT statements
- SWT type Members
- Provide description of the templates
- Now under Pattern we need to define our own template based on context lets see a very simple example.
- I create simple baseFunction with template name as bone provide javadoc also please check the images.
Once we type bone and Press Ctrl+Space then it will give complete
template.
1 Comments
Slot Machine Rental - Las Vegas - MapYRO
ReplyDeleteSlot Machine Rentals are a great way to do Las Vegas research. Find 원주 출장샵 and 의왕 출장마사지 rent real photos 충주 출장안마 of your favorite slot machine from Mapyro 안성 출장안마 here! 전라북도 출장마사지