[英]How do I stop eclipse from removing whitespace when formatting
I am using eclipse to do some LWJGL programming and when I create arrays for holding the vertices, I tend to use a lot of whitespace to show what group of floats hold a vertex. 我正在使用eclipse做一些LWJGL编程,当我创建用于保存顶点的数组时,我倾向于使用大量的空格来显示哪些浮点数包含顶点。
//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
};
I should also note that I am using element array buffers so that is why there are only 7 vertices. 我还应该注意到我正在使用元素数组缓冲区,这就是为什么只有7个顶点。
When I use the Format option in the Source tab of the menu bar, it strips all of this whitespace. 当我在菜单栏的Source选项卡中使用Format选项时,它会删除所有这些空格。 How do I stop it from doing that? 我如何阻止它这样做? I cannot find an option in the preferences editor. 我在首选项编辑器中找不到选项。
I am using Windows 8.1 and Eclipse Java Neon. 我使用的是Windows 8.1和Eclipse Java Neon。 And no, I won't use a different version of Eclipse as it took me about 5 hours customizing eclipse initially so... If there is a newer version that allows this to be done, I will not be changing the version. 不,我不会使用不同版本的Eclipse,因为我花了大约5个小时来定制eclipse所以...如果有一个新版本允许这样做,我将不会更改版本。 It would also take a while to install and stuff so... yeah. 安装和填充也需要一段时间......是的。
Disable the Eclipse formatter for the part of code where you want to ignore the formatter and re-enable it in this way : 对于要忽略格式化程序的代码部分禁用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
You must enable this feature if it is not already done. 如果尚未启用此功能,则必须启用此功能。
Preferences->Java->Code Style->Formatter->Edit->Off/On Tags Preferences-> Java-> Code Style-> Formatter-> Edit-> Off / On Tags
转到首选项 - > Java->代码样式 - >格式化程序 - >编辑并更改相关选项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.