最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Eclipse Java formatter - do not change comment indentation - Stack Overflow

programmeradmin5浏览0评论

I am trying to stop Eclipse changing the indentation of comments when using the formatter. e.g.

public class Test
{
    public static void main(String[] args)
    {
        // comment 1
        if (true != false &&
                // comment 2
                false != true)
        {
            
        }
            
    }
}

Gets formatted to

public class Test
{
    public static void main(String[] args)
    {
        // comment 1
        if (true != false &&
        // comment 2
                false != true)
        {

        }

    }
}

I don't want the formatter to move 'comment 2'

My eclipse formatter settings are:

I have tried unchecking the 'never indent' options as well.

Is there a way to get eclipse to stop doing this, or completely ignore lines that start with // ? This is a legacy codebase so I can't easily change the approach. Ideally I want to be able to format files on save so I don't want to use formatter on/off tags.

I am on Eclipse for Java developers version 2024-12 (4.34)

发布评论

评论列表(0)

  1. 暂无评论