Line breaks between function definitions

南楼画角 提交于 2019-12-12 10:29:33

问题


Is there any way to to automatically insert spaces between function definitions. E.g. my initial sources are:

void
func1()
{
    // func1 body.
}
void
func2()
{
    // func2 body.
}

I would like it to be reformatted to:

void
func1()
{
    // func1 body.
}


void
func2()
{
    // func2 body.
}

And if there are more line breaks, fixed number of them should be kept.


回答1:


As far as I can tell, there's currently no way to force clang-format to insert blank lines between consecutive functions where there currently are none. IMHO this is a huge missing feature.




回答2:


Your best bet is to set 'MaxEmptyLinesToKeep: 2' inside .clang-format file to let clang-format keep 2 lines intact.



来源:https://stackoverflow.com/questions/27121457/line-breaks-between-function-definitions

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!