Ada*_*dam 22 eclipse formatting eclipse-cdt
我遇到了Eclipse格式化程序的问题.在类声明中声明方法时,它不会正确格式化我的代码.它在方法的返回类型后面添加一个新行.
我已经导出了样式xml文件并检查了其中的设置,但是没有任何设置与此问题有任何明显的联系,并且Eclipse中的设置编辑器没有显示其方法声明的示例代码中发生的相同问题.
以下是我想要发生的代码示例:
class MyClass
{
public:
MyClass();
void myMethod();
};
Run Code Online (Sandbox Code Playgroud)
但是,这就是我得到的:
class MyClass
{
public:
MyClass();
void
myMethod();
};
Run Code Online (Sandbox Code Playgroud)
同样,在样式编辑器中,代码没有这个问题,看起来就像我想要的那样,但在实际的代码中,故事是不同的.
我使用的是3.8.0版本.任何帮助表示赞赏.
编辑:我删除那些格式不正确的源文件(格式化代码几次后无效)并用相同的方法,相同的结构等替换它们"相同"的文件.我这次格式化代码,它工作.这可能是一个错误,但是我将其留下以防万一其他人遇到类似的问题或者首先要解决这个问题.
小智 19
我在主eclipse项目目录下编辑了两个文件
.metadata\.plugins\org.eclipse.core.runtime\.settings
Run Code Online (Sandbox Code Playgroud)
这两个文件:
file 1: org.eclipse.cdt.core.prefs, change this line from "insert" to "do not insert"
org.eclipse.cdt.core.formatter.insert_new_line_before_identifier_in_function_declaration=do not insert
file 2: org.eclipse.cdt.ui.prefs,
scan this file for "insert_new_line_before_identifier_in_function_declaration" and make a similar change from insert to do not insert next to it, should be obvious
Run Code Online (Sandbox Code Playgroud)
注意我在indigo和juno上看到了这个问题,上面描述的修复是在juno中.
如果您有自定义格式化程序配置,请先将其导出(设置> C/C++常规>格式化程序>编辑>导出).然后将以下行更改为"不插入".保存XML.
<setting id="org.eclipse.cdt.core.formatter.insert_new_line_before_identifier_in_function_declaration" value="do not insert"/>
Run Code Online (Sandbox Code Playgroud)
删除当前配置并导入您更改的配置.
| 归档时间: |
|
| 查看次数: |
7536 次 |
| 最近记录: |