问题描述
当我创建新类 MyClass
时,CLion创建 MyClass.h
和 MyClass。 cpp
,但我想要 my_class.h
和 my_class.cpp
。当我尝试重命名文件时,它会将类重命名为 class my_class {}
。如何获得 class MyClass {}
和 my_class.h
, my_class.cpp
?
When I create new class MyClass
, CLion creates MyClass.h
and MyClass.cpp
, but I want my_class.h
and my_class.cpp
. And when I try to rename files it renames class to class my_class {}
. How can I have class MyClass {}
and my_class.h
, my_class.cpp
?
推荐答案
您必须编写一些Apache Velocity引擎代码才能做到这一点。在CLion首选项内,您可以调整文件创建模板设置(类似的事情,我没有在此处打开CLion来查找它)并编写如下内容:
You have to write some Apache Velocity engine code to do that. Inside the CLion preferences you can adjust the file creation template settings (something like that, I don't have CLion open here to look it up) and write something like:
#set( $CamelCaseName = "" )
#set( $part = "" )
#foreach($part in $NAME.split("-"))
#set( $CamelCaseName = "${CamelCaseName}$part.substring(0,1).toUpperCase()$part.substring(1).toLowerCase()" )
#end
这篇关于如何在CLion中使用蛇形大小写作为文件名和驼峰式大小写作为文件名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!