【问题标题】:How do you copy java code from a java file from eclipse without messing up the format?如何从 eclipse 的 java 文件中复制 java 代码而不弄乱格式?
【发布时间】:2022-01-04 06:03:01
【问题描述】:

我一直在尝试从我的 Eclipse 程序中复制代码,以便可以通过电子邮件将其发送给我正在使用的人,但格式被弄乱了。这就是我想要的样子:

while (insOrDel) {// Asks the user for five different options:
            // add a username or bot
            // add a special username or bot
            // remove a username or bot
            // remove a special username or bot.
            // list all special usernames or bots.
            // list all usernames or bots
            // run weblog sifter.

但是,当它从电子邮件中出来时,它最终是这样的:


        while (insOrDel) {// Asks the user for five different options:
// add a username or bot
// add a special username or bot
// remove a username or bot
// remove a special username or bot.
// list all special usernames or bots.
// list all usernames or bots
// run weblog sifter.

请记住,这是在 Ctrl+Shift+F 之后,并且由于某种原因,cmets 没有缩进。有没有办法解决这个问题?

谢谢!

【问题讨论】:

  • 为什么不将java文件作为附件发送?

标签: java eclipse format


【解决方案1】:

当源文件使用制表符且您粘贴代码的目标应用具有不同的制表符宽度时,可能会发生这种情况。

为避免这种情况,您可以在 Eclipse /Window / Preferences / General / Editors / Text Editors 中设置选项'Insert spaces for tabs'

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多