Stop Eclipse from mangling my comments

前端 未结 5 1544
臣服心动
臣服心动 2020-12-29 23:53

Is there a way to stop eclipse from mangling the comments in my source files?

My main issue is stopping it from word wrapping them. I\'ve managed to configure eclips

相关标签:
5条回答
  • 2020-12-30 00:28

    There is another solution that you can use to suppress the formatting of specific block comments. Use /*- (note the hyphen) at the beginning of the block comment, and the formatting won't be affected if you format the rest of the file.

    /*-
     * Here is a block comment with some very special
     * formatting that I want indent(1) to ignore.
     *
     *    one
     *        two
     *            three
     */
    

    Source: http://www.oracle.com/technetwork/java/javase/documentation/codeconventions-141999.html#680

    0 讨论(0)
  • 2020-12-30 00:32

    Go to the "Window" menu -> preferences
    choose the editor you're interested in from the list on the left.(e.g. Java)
    then there should be a subsection called "Code Style", and under that "Formatter".

    Then you'll need to create a new formatter profile. (The built-in profile can't be edited) On the last tab of the profile configuration is options for comment formatting

    0 讨论(0)
  • 2020-12-30 00:32

    You can use <pre></pre> wrapped, this block will not format.

    /*
     * <pre class="prettyprint">
     * public class Activity extends ApplicationContext {
     *     protected void onCreate(Bundle savedInstanceState);
     *
     *     protected void onStart();
     *
     *     protected void onRestart();
     *
     *     protected void onResume();
     *
     *     protected void onPause();
     *
     *     protected void onStop();
     *
     *     protected void onDestroy();
     * }
     * </pre>
     */
    
    0 讨论(0)
  • 2020-12-30 00:33

    Window->Preferences->Java->Code Style->Formatter. Create new formatter. Click on edit and then pick tab Comments unchecked Enable Line comment formatting and Enable block comment formatting

    0 讨论(0)
  • 2020-12-30 00:45
    1. Go to Preferences -> Java -> Code Style -> Formatter
    2. There edit the profile and switch to the last tab called "Comments"
    3. Uncheck the "Enable line comment formatting"
    0 讨论(0)
提交回复
热议问题