How to use snake case for file names and camel case for file names in CLion?

六月ゝ 毕业季﹏ 提交于 2019-12-13 15:53:39

问题


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?


回答1:


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



回答2:


You can go to "Settings -> Editor -> Code Style -> C/C++ -> New File Extensions" and change "File Naming Convention".



来源:https://stackoverflow.com/questions/38037467/how-to-use-snake-case-for-file-names-and-camel-case-for-file-names-in-clion

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