`

How to Change the Default Format Settings in Eclipse(转载)

 
阅读更多

--http://www.wikihow.com/Change-the-Default-Format-Settings-in-Eclipse

 

How to Change the Default Format Settings in Eclipse

Do you get tired on constantly having to re-format your programming code? With a single press of Control+Shift+F, Eclipse will format your entire document for you. Follow the below steps to change the way Eclipse will format your document to your personal preferences.

 
 
 

Steps

  1. Change the Default Format Settings in Eclipse Step 1.jpg
    1
    Have the Eclipse program open. Click the Window option in the top tool bar and then click Preferences.
     
    Ad
    <iframe id="aswift_0" style="position: absolute; margin: 0px; top: 0px; left: 0px; padding: 0px;" name="aswift_0" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" width="600" height="120"></iframe>
     
  2. Change the Default Format Settings in Eclipse Step 2.jpg
    2
    On the left side of the box, expand the Java option, then expand Code Style and finally click Formatter.
     
  3. Change the Default Format Settings in Eclipse Step 3.jpg
    3
    The active profile should be set to “Eclipse [built-in]” you cannot edit this setting, so we will make a new one by clicking the “New...” button underneath.
     
  4. Change the Default Format Settings in Eclipse Step 4.jpg
    4
    In the “profile name” pick a name that is significant to you so that you will remember what it is. The “Initialize setting with the following profile” option should have “Eclipse [built-in]” selected. And the “Open the edit dialog now” should also be selected. Now click “OK” to create your new format settings.
     
  5. Change the Default Format Settings in Eclipse Step 5.jpg
    5
    You are now presented with the “Profile ‘name you selected’” box. There will be 8 tabs, named as follows:
    • Indentation
    • Braces
    • White space
    • Blank lines
    • New lines
    • Control statements
    • Line wrapping
    • Comments
      There will be an “Apply” and “OK” button at the bottom. You should make sure that you hit the “Apply” button every time you make a change so that it will know it is definitely saved and applied to your format settings.
     
  6. Change the Default Format Settings in Eclipse Step 6.jpg
    6
    Refer to the picture at the right to see the INDENTATION TAB. Indentation is very important because it makes a program more readable if done properly. In the General Settings area, you can change the size of the tab, which you can set depending on whether you want to save space or if you want to differentiate the different sections more easily. According to coding conventions, you should leave all the boxes in the Indent section checked (Empty lines box does not matter). Do not forget to click Apply.
     
  7. Change the Default Format Settings in Eclipse Step 7.jpg
    7
    Click on the BRACES TAB, and refer to the picture to the right if necessary.The braces settings are fairly simple and are based on personal preference. Most people either use the “Same line” or “Next line” position. You should use the same position for every option. Do not forget to click Apply.
     
  8. Change the Default Format Settings in Eclipse Step 8.jpg
    8
    Click the WHITE SPACE TAB. Use the picture to the right for reference. Once again, this tab is for personal preference and ease of reading. There are many options to expand, read through and then select or deselect according to your preference on where you want a space (means one click of the space bar) to be added or removed. Do not forget to look in the preview window to see the change and click Apply often, seeing as there are many options in this tab.
     
  9. Change the Default Format Settings in Eclipse Step 9.jpg
    9
    Click the BLANK LINES TAB and use the picture as a reference. This tab allows you to specify the number of blanks lines before or after different declarations. The standard is usually either 0 or 1 depending on the option. If you use more than 1 blank line, it is just wasting space. Choose the options according to you preference. Do not forget to select Apply.
     
  10. Change the Default Format Settings in Eclipse Step 10.jpg
    10
    Look at the picture to the right and then click on the NEW LINES TAB. This tab is purely for user preference, so choose options as you desire. Do not forget to click Apply.
     
  11. Change the Default Format Settings in Eclipse Step 11.jpg
    11
    Once again, the CONTROL STATEMENTS TAB is for your personal preference. Refer to the picture to the right, while selecting the boxes. The document is easily read with or without the added space after a control statement. To limit the length of your document leave the boxes unchecked. Do not forget to click Apply.
     
  12. Change the Default Format Settings in Eclipse Step 12.jpg
    12
    Click the LINE WRAPPING TAB and see the picture to the right. In the “Line width and indentation levels” section choose how many characters wide your document can be and how wide you want the indent to be for the wrapping of the line(s). Below, click each option and choose the “Line wrapping policy” and “Indentation policy” accordingly. You want your document to have the littlest amount of wrapping as possible, so that it is easy to read. Do not forget to select Apply often, since there are a lot of options.
     
  13. Change the Default Format Settings in Eclipse Step 13.jpg
    13
    The COMMENTS TAB is the last tab to set and the picture to the right is for reference. The options that begin with “Enable...” should be selected. The other options can be selected for personal preference. I also recommend selecting all the options that will “Remove blank lines.” Do not forget to click Apply.
     
  14. Change the Default Format Settings in Eclipse Step 14.jpg
    14
    As an example, to show you how the format will work, there is a sample program (click on the picture at the right) shown with the formatting distorted (i.e. wrong indentation, extra spaces, etc.).
     
  15. Change the Default Format Settings in Eclipse Step 15.jpg
    15
    To format the currently selected document, click on Source in the top tool bar and then click Format or as a shortcut you can click “Control + Shift + F”.
     
  16. Change the Default Format Settings in Eclipse Step 16.jpg
    16
    Again, click on the picture to the right. Here you can see that the indentation has been restored, excess space has been removed and brackets are placed as per my preference. You document will not, necessarily look like mine as it will be based on your personal coding style preference.
分享到:
评论

相关推荐

    How to start developing Spark applications in Eclipse

    How to start developing Spark applications in Eclipse By Marko Bonaći In this article, you will learn to write Spark applications using Eclipse, the most widely used development environment for JVM-...

    how to use eclipse

    然而,根据“how to use eclipse”这一标题,我将基于这一假设,提供Eclipse开发环境(IDE)的使用方法。 Eclipse是Java开发环境中广泛使用的一款集成开发工具,它是由Eclipse基金会维护的一个开源项目。Eclipse ...

    ac_records_system.zip_How To Change It

    you can add & view records. It is automatically generate on EXCEL, MSWORD, NOTEPAD and also to any other office encoder. How to change extension format files LIKE .csv .doc .txt

    C++ How to Program, 10th Edition

    C++ How to Program presents leading-edge computing technologies in a friendly manner appropriate for introductory college course sequences, based on the curriculum recommendations of two key ...

    Eclipse Rich Ajax Platform: Bringing Rich Client to the Web

    Eclipse Rich Ajax Platform: Bringing Rich Client to the Web Paperback: 148 pages Publisher: Apress; 1 edition (December 29, 2008) Language: English ISBN-10: 1430218835 ISBN-13: 978-1430218838 ...

    How to use SFTP

    You should ensure that the server's public keys are loaded by the client as described in How to use SFTP (with server validation - known hosts), or you may want to switch off server validation to get ...

    How_to_write_and_publish_a_scientific_paper

    对研究生很有用的,叫你怎麽写英语论文 How to write and publish a scientific paper ContentsChapter 1 What Is Scientific Writing? Chapter 2 Origins of ...Chapter 11 How to State the Acknowledgments

    log4j-tutorial.zip_How To Change It

    This tutorial explains how to set up ...properties configuration files, shows how to change LogLevels for a running application. Furthermore, we explain best practices on logging and exception handling.

    Spring Boot in Action

    Spring expert Craig Walls uses interesting and practical examples to teach you both how to use the default settings effectively and how to override and customize Spring Boot for your unique ...

    spring boot in action

    Spring expert Craig Walls uses interesting and practical examples to teach you both how to use the default settings effectively and how to override and customize Spring Boot for your unique ...

    Write To The Point - How To Communicate In Business With Style And Purpose - S J Iacone (Career Press) - 2003.chm

    This book provides practical, proven techniques for making writing for ... All levels of business and technical personnel will find this easy-to-read guide invaluable and immediately useful every day.

    how to solve it

    George Polya revealed how the mathematical method of demonstrating a proof or finding an unknown can be of help in attacking any problem that can be "reasoned" out - from building a bridge to winning...

    Simple application that shows how to use the Data Control to

    Simple application that shows how to use the Data Control to connect to the Biblio.mdb database and display all authors in the Authors table.

    Eclipse AspectJ: Aspect-Oriented Programming

    This book is an introduction to AOP with AspectJ and Eclipse and shows how to create a productive AO development environment by using the AspectJ Development Tools for Eclipse (AJDT). Tools have an ...

    Manning - Eclipse In Action.pdf

    The book titled "Eclipse in Action" provides a detailed guide for web developers on how to effectively use the Eclipse Integrated Development Environment (IDE). The authors, David Gallardo, Ed ...

Global site tag (gtag.js) - Google Analytics