在Intellij中,如何在驼峰大小写和下划线之间切换? [英] In Intellij, how do I toggle between camel case and underscore spaced?

查看:83
本文介绍了在Intellij中,如何在驼峰大小写和下划线之间切换?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我公司,我们有两种针对Java和sql的样式指南。在Java中,我有一个名为 historyOfPresentIllness 的字段,当我编写sql时,我想将其命名为 history_of_present_illness 。当我突出显示该短语时,是否有键盘快捷键可以从一个切换到另一个?还是可以做到这一点的插件?

At my company we have two different style guides for java vs sql. In java I have a field named historyOfPresentIllness and when i write the sql, I want to name it history_of_present_illness. Is there a keyboard shortcut to switch from one to the other when I have the phrase highlighted? Or perhaps a plugin that can do this?

在我问的同时,我也可能会问是否有办法将 historyOfPresentIllness 转换为当前病史。从Java到clojure风格。

While I'm asking, I may as well ask if there's a way to turn historyOfPresentIllness to history-of-present-illness. That's from java to clojure style.

推荐答案

我使用了名为字符串处理具有您正在寻找的功能(以及更多功能)。

I use a plugin called String Manipulation which has the capabilities you're looking for (and more).

选择 historyOfPresentIllness 并按 Alt + M 调出插件菜单,然后按:

Select historyOfPresentIllness and press Alt+M to bring up the plugin menu, then press:


  • 5 -转到snake_case(或camelCase) 转换为 history_of_present_illness

  • 6 -连字符(或到snake_case)转换为当前病史

  • 5 - To snake_case (or to camelCase) which converts to history_of_present_illness
  • 6 - To hyphen-case (or to snake_case) which converts to history-of-present-illness

要使此操作更容易,您可以在 File | File |中设置快捷方式。设置|键盘映射



快速搜索 camel的插件存储库,发现一个名为 CamelCase 可以通过在 SHIFT + ALT + U 之间进行切换来完全满足您的需求各种格式:

To make this easier, you could set up a shortcut at File | Settings | Keymap.


A quick search of the plugin repository for "camel" showed a plugin called CamelCase which does exactly what you're looking for with SHIFT+ALT+U by toggling between various formats:

historyOfPresentIllness -> history_of_present_illness - -> HISTORY_OF_PRESENT_ILLNESS -> HistoryOfPresentIllness -> historyOfPresentIllness

historyOfPresentIllness --> history_of_present_illness --> HISTORY_OF_PRESENT_ILLNESS --> HistoryOfPresentIllness --> historyOfPresentIllness

但是,尝试之后,此插件似乎存在一个错误,阻止您撤消任何更改。 更新::此错误似乎已经修复了一段时间,因此CamelCase插件可能是解决方法。

However, after trying it out, there seems to be a bug with this plugin which prevents you from undoing any changes. Update: it appears this bug has been fixed for a while now, so the CamelCase plugin is probably the way to go.

这篇关于在Intellij中,如何在驼峰大小写和下划线之间切换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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