如何在CLion中使用蛇形大小写作为文件名和驼峰式大小写作为文件名? [英] How to use snake case for file names and camel case for file names in CLion?

查看:296
本文介绍了如何在CLion中使用蛇形大小写作为文件名和驼峰式大小写作为文件名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我创建新类 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中使用蛇形大小写作为文件名和驼峰式大小写作为文件名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆