Eclipse,GitHub - 文本格式/制表符缩进问题

时间:2011-07-17 19:50:43

标签: eclipse text tabs github format

我正在使用基于Eclipse的编辑器(Flash Builder)来编写我的代码。我想使用GitHub作为远程存储库,但是由于选项卡缩进而导致格式冲突。

例如,在Flash Builder中,我写了这个:

case Boolean:       bytes.writeBoolean(value);          break;                  
case int:           bytes.writeInt(value);              break;
case uint:          bytes.writeUnsignedInt(value);      break;
case Number:        bytes.writeDouble(value);           break;
case ByteArray:     bytes.writeBytes(value);            break;
default:            bytes.writeUTFBytes(value);

但是当它被发送到GitHub(或纯文本文件)时,它会显示如下:

case Boolean:       bytes.writeBoolean(value);          break;
case int:                bytes.writeInt(value);                 break;
case uint:               bytes.writeUnsignedInt(value);     break;
case Number:        bytes.writeDouble(value);           break;
case ByteArray:     bytes.writeBytes(value);            break;
default:                 bytes.writeUTFBytes(value);

如果我从GitHub中取出存储库并在代码编辑器中打开文件,格式仍然正确,因此它似乎不会改变格式,而是显示错误。

这是可以修复的吗?

1 个答案:

答案 0 :(得分:2)

听起来好像使用制表符作为分隔符,不同的编辑器有不同的制表符空格。这就是为什么我总是使用(4)空格而不是制表符。您可以通过选中以下命令将Eclipse配置为始终使用空格:

Window->Preferences->General->Editors->Text Editors->Insert spaces for tabs