Eclipse Auto-typesetting shortcut key invalidation

Source: Internet
Author: User

Format code (Eclipse format code block shortcut: CTRL+SHIFT+F)

1. Format the Java code:

①ctrl+shift+f

But we're going to encounter a time when pressing CTRL+SHIFT+F doesn't work?
Ctrl+shift+f in Sogou pinyin is simple and complex replacement. Once installed Sogou Pinyin This shortcut is occupied, but you can set the Sogou shortcut keys for other simple. In other cases, you can use formatting shortcuts in eclipse.
In fact, can generally be summed up as these: 1.Ctrl or shift or F key is broken;
2. The whole keyboard problem;
3.ctrl+shift+f shortcut keys are used by other software (such as: sogou Pinyin, Baidu Pinyin).

②eclipse automatically formatting code when saving files

Many do not know that eclipse has a very useful function, is the automatic format source code function, generally we are directly ctrl+shift+f manual format, a waste of time.

In fact, Eclipse already has the automatic format function, the default is not to open this function.
How to: Windows-->preferences-->java---editor-->save actions, see options on the right, tick "Perform the selected actions on Save ", other options can be selected or configured as needed.
Don't forget to apply and OK at the end.


2. Format the XML code: CTRL+SHIFT+F, but make the following changes

However, for XML files, sometimes after formatting, the configuration properties of a control are all squeezed in one line, and it is inconvenient to read and modify them.
And we want the best formatting effect as follows, each property of the control is configured with one row for easy reading and modification, and the control with no child elements is closed using/> directly:
<?xml version= "1.0" encoding= "Utf-8"?>
<linearlayout xmlns:android= "Http://schemas.android.com/apk/res/android"
Android:layout_width= "Fill_parent"

android:layout_height= "Fill_parent"/>

android:text= "Some Content"
Android:layout_width= "Wrap_content"
android:layout_height= "Wrap_content"/>
</LinearLayout>
To achieve these formatting effects, you need to modify some of the eclipse's configuration and perform some additional operations:
to modify the XML format configuration of Eclipse:
The configuration of this step is to make the formatted effect one row for each property configuration of the control. Enter Window/preferences, expand to Xml/xml files/editor,

Tick "Split multiple attributes each in a new line" as shown in:


<textview android:id= "@+id/textview01"

Eclipse Auto-Typesetting shortcut key invalidation (GO)

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.