简体   繁体   中英

How do you copy java code from a java file from eclipse without messing up the format?

I have been trying to copy code from my eclipse program so I can email it to someone that I'm working with, but the format is messed up. This is what I want it to look like:

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.

However, it ends up like this when it comes out of the email:


        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.

Keep in mind this is after Ctrl+Shift+F, and for some reason, the comments aren't indented. Is there a way to fix this?

Thanks!

This can happen when source file uses Tab characters and the destination app you pasting your code in has a different tabwidth.

To avoid this you can set in Eclipse / Window / Preferences / General / Editors / Text Editors the option 'Insert spaces for tabs'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM