gpt4 book ai didi

java - 格式化时如何阻止 Eclipse 删除空格

转载 作者:塔克拉玛干 更新时间:2023-11-01 22:40:55 28 4
gpt4 key购买 nike

我正在使用 eclipse 进行一些 LWJGL 编程,当我创建用于保存顶点的数组时,我倾向于使用大量空白来显示哪组 float 保存一个顶点。

//Array for holding the vertices of a hexagon
float [ ] Vertices = {
// Vertex 0
-0.5f , 1.0f , 0.0f ,
// Vertex 1
-1.0f , 0.0f , 0.0f ,
// Vertex 2
-0.5f , -1.0f , 0.0f ,
// Vertex 3
0.5f , -1.0f , 0.0f ,
// Vertex 4
1.0f , 0.0f , 0.0f ,
// Vertex 5
0.5f , 1.0f , 0.0f ,
// Center Vertex ( 6 )
0.0f , 0.0f , 0.0f

};

我还应该注意,我正在使用元素数组缓冲区,所以这就是为什么只有 7 个顶点的原因。

当我在菜单栏的“源代码”选项卡中使用“格式”选项时,它会去除所有这些空白。我如何阻止它这样做?我在首选项编辑器中找不到选项。

我正在使用 Windows 8.1 和 Eclipse Java Neon。不,我不会使用不同版本的 Eclipse,因为最初定制 Eclipse 花了我大约 5 个小时,所以...如果有更新的版本允许完成此操作,我将不会更改版本。安装和其他东西也需要一些时间......是的。

最佳答案

为要忽略格式化程序的代码部分禁用 Eclipse 格式化程序,然后以这种方式重新启用它:

//Array for holding the vertices of a hexagon
// @formatter:off
float [ ] Vertices = {
// Vertex 0
-0.5f , 1.0f , 0.0f ,
// Vertex 1
-1.0f , 0.0f , 0.0f ,
// Vertex 2
-0.5f , -1.0f , 0.0f ,
// Vertex 3
0.5f , -1.0f , 0.0f ,
// Vertex 4
1.0f , 0.0f , 0.0f ,
// Vertex 5
0.5f , 1.0f , 0.0f ,
// Center Vertex ( 6 )
0.0f , 0.0f , 0.0f
};
// @formatter:on

如果尚未启用此功能,则必须启用它。
Preferences->Java->Code Style->Formatter->Edit->Off/On Tags

关于java - 格式化时如何阻止 Eclipse 删除空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38696727/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com