Compatibility configuration with Eclipse development

Source: Internet
Author: User

Usually when using the Eclipse development program, normally it is not a problem to run in Linux, the most obvious is the coding problem, this is generally unified for utf-8, and also the Windows and Linux line break different reasons, There are contemporary code uploaded to GitHub and other platforms, view indentation will be chaotic, so these places need to unify, to Linux as standard, because it is more concise, all the code in addition to UTF-8 encoding, do not use tab indentation, it is recommended to uniformly use 4 spaces or 2 spaces indent, The line-wrapping style is all Linux/unix style, \ n, which guarantees most code compatibility issues, which are set in eclipse

Set all in the top menu bar "window", "Preferences" action

1. Set Indent to 4 spaces

In the dialog box, select "General", "Editors", "Text Editors"

In the right displayed tab width: text box you can see the default is 4, and then at this point in the Insert spaces for tabs box before the tick, indicating that the tab to a space, now is exactly 4

  

After you save these settings, do not move, click OK to confirm

2. Set Java indent to 4 spaces

The above settings are for normal files, but also for Java source files to set their indentation style

Select Java, Code Style, Formatter, then click Edit on the right ... Go to the Edit screen

  

First Set tab policy: For spaces only the default is tabs only is the tab indentation, and then modify the profile name can not be saved, after setting these two, save

  

3. Set encoding and line wrapping style

Select "General", "Workspace", which defaults to default (GBK) in the right text file encoding, this place must be modified to other UTF-8

Then new text file line delimiter is default (Windows) is recommended to modify to other Unix and then determine

  

Note: The utf-8 here is not with the BOM head, which is pure

After modifying the above 3 items, the cross-platform compatibility problem with the code basically solves

Compatibility configuration with Eclipse development

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.