Efficient use of Eclipse

Source: Internet
Author: User
Tags diff sublime text

工欲善其事, its prerequisite

As an Android programmer, Eclipse should be your first IDE to get started, and of course you can choose the legendary artifact: Android Studio or IntelliJ IDEA . The difference between eclipse and these newly promoted artifacts is not discussed here (Portal: where is Android studio better than Eclipse?) We simply start with eclipse and how to improve our productivity.

Set up your file Encoding

For many children's shoes, there File Encoding is no habit of setting, and its comments are often Chinese comments, in order to our comments in other people's machine normal display, to prevent garbled breeding, please modify the text encoding method for UTF-8.
How to set : Window→preferences→general→workspace→text file Encoding, set to UTF-8

Font selection

Each programmer has a set of favorite programming fonts, and for those who seek perfection in their senses, a good font usually minimizes the distraction of your programming. Usually, the Eclipse default font Courier New is, 10th font, looks good, but we have a better font to choose from, whether it is displayed in English or Chinese, is perfect, that Consolas is, the font size is 11.
How to set : Window→preferences→general→appearence Colors and Fonts, select Java-java Editor Text font in the right dialog box, set the programming font, when However, fonts such as dialog boxes can also be set here.
More Perfect programming fonts See: 10 best-performing programming fonts
Finally, we recommend an open-source, equal-width font from adobe: Source Code Pro, which is very beautiful.

Theme

If you are tired of changing to adjust font, text color and other tedious things, we also have a unified solution, is Eclipse Color Theme the plugin, it can provide you with a lot of very beautiful themes, such as sublime Text 2, Obsidian, notepad++ Like dozens of themes, enough to meet the needs of a variety of people, it is powerful: Eclipse Color Themes
How to install :
Step 1: Installation Marketplace : http://download.eclipse.org/mpc/indigo/
Step 2: By Marketplace installing the plugin
Of course, you can also install this plugin directly by clicking Help→install New Software in Eclipse, please Google for details.

IntelliSense Java

Intelligent perception is undoubtedly the most direct way to speed up programming. By default, when we write Java programs, only when we encounter the English period . , or manually press Alt+/ , eclipse will show the code hints, very inconvenient, how to enter any character, let the smart prompt box display it?
How to set : Window→preferences→java→editor→content Assist, set auto activation triggers for Java:
.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVW_(, in addition, to speed up the smart cue box trigger time, we set 20 Auto activation delay (MS) to
After setting:

Xml

For Android programmers, often to write XML layout files, but there is a very headache, the XML is not a sense of intelligence, only in the presence <=: of a smart prompt box, how to solve it?
In fact, the solution is like setting up Java IntelliSense.
How to set : Window→preferences→xml→xml files→editor→content assist→auto Activation, setting prompt when Thiese char Acters is inserted: .abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_(<=: and sets 20 auto activation delay (MS) to
After setting:

#与 @

Most lazy people and those who do not like to write comments, will complain that the comments are difficult to write, too easy to distract, as a programmer, if not even comment on writing, I personally think this is a very irresponsible programmer, because the software life of the software 80% is spent on maintenance, the consequences of not writing annotations is more serious, It greatly improves the difficulty of software maintenance, the amount ... Is it really hard to write a note? As for how to write professional notes, I do not explain too much, just provide two simple tricks.
Tips for adding comments to your code: using @# activation JavaDoc
@: Add keywords in a document

/** * 该类是整个 DEMO 程序的入口。 *  * @author XXX * @date 2013-09-29 */publicclass DemoMainActivity extends Activity {

#: Add code link

/** * Calls {@link android.view.Window#getCurrentFocus} on the * Window of this Activity to return the currently focused view. *  * @return View The current View with focus or null. *  * @see #getWindow * @see android.view.Window#getCurrentFocus */publicgetCurrentFocus() {    returnnullnull;}

Shortcut keys

The importance of the shortcut is needless to say, in order to speed up the coding, reading the efficiency of the code, I think everyone should master the following commonly used shortcut keys. If you have forgotten the shortcut key, you can view it by Ctrl-Shift-L opening the shortcut window.

Learn about the Eclipse shortcut keys that your code must master
Eclipse shortcut keys 10 most useful shortcuts

Integrated SVN and beyond Compare

Integrating SVN into eclipse is a great way to get us out of the Windows folder. In the early days, I didn't trust this SVN plugin much more, because it was a bit more fun to use directly, and TortoiseSVN + Beyond Compare the SVN plug-in's comparison tool was too poor to compare the code for extreme discomfort.

SVN plug-in selection

Now there are two good plugins on the market:
-Subversive (officially produced by Eclipse team)
-Subclipse (SVN team official)

The pros and cons of them can look at this article: Subclipse vs Subversive

I chose Subversion it because it was Beyond Compare 3 simpler to configure and Subclipse I configured it for a long time.
How to install the Subversion plugin :
-Install directly from Eclipse Marketplace
-by Help → Install New Software Installing the plugin
http://community.polarion.com/projects/subversive/download/eclipse/3.0/juno-site/

In addition, when using subversion, when selecting SVN Connector , select JavaHL (Note the version selection)

Configuring Beyond Compare 3 in SVN

If you're used to Beyondcompare compare file styles and then use the SVN native comparison style, you'll feel miserable, so it's necessary for beyondcompare to be able to configure the SVN plugin.

How to configure :
Step 1:window→preferences→team→svn→diff Viewer
Step 2: Click Add , set file type to any file, i.e. add in Extension or mime-type *
Step 3: Select the file path of the Beyond compare (note the path with double quotes),
To set the parameters in diff: "${base}" "${mine}"
To set the parameters in the merge:

"${theirs}" "${mine}" "${base}" "${merged}"
/lefttitle="Incoming (${theirs})"
/centertitle="Base (${base})"
/righttitle="Local (${mine})"
/outputtitle="Merged (${merged})"


Java Code Style various configurations

The various configurations of the Java code style mainly refer to the coding specifications for the configuration of our code, such as line breaks, spaces, annotations, and so on.
Can be under the Window→preferences→java→code style, yes, Clean Up Code Templates , to Formatter configure, in general, a team, in order to unify the coding style, we need to have some unified style template, The following three links are currently a template I do, for reference only.
-Clean up
-Code Template
-Formatter

How to use : Save the above three files to Formatter example, in the Formatter interface, click Import Import, the other two similar.

Efficient use of Eclipse

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.