开发者

Is there a way to quickly capitalize the variable name in Eclipse

开发者 https://www.devze.com 2023-02-16 23:15 出处:网络
Any refac开发者_JAVA技巧toring tool like this?Windows After you press Alt+Shift+R as mentioned by kostja, you can select the text you want to change, then

Any refac开发者_JAVA技巧toring tool like this?


Windows

After you press Alt+Shift+R as mentioned by kostja, you can select the text you want to change, then

  • Ctrl+Shift+Y for lowercase, or
  • Ctrl+Shift+X for uppercase.

Mac OS

  • Cmd+Shift+Y lowercase
  • Cmd+Shift+X uppercase

There is no intelligence in this. It just blindly changes the case on the selected characters.

note: This tip comes from eclipse help. If you need to find it, click Help, Search, then type "uppercase". You'll find a page with lots of shortcuts.


What I find useful is column select using Alt+Shift+A and select a column of letters. Then use Ctrl+Shift+Y or Ctrl+Shift+X to lower case or uppercase letters.

This works for eclipse on windows.


There are a number of problems:

  • fooBar -> FooBar and vice-versa are unlikely to occur unless someone has been ignoring the Java style guidelines. (I rarely encounter such code, and when I do my initial reaction is to write off the code as beyond salvage.)

  • fooBar -> FOO_BAR and vice-versa are plausible, but pretty unusual.

  • foobar -> fooBar is also plausible, but it is problematic. It would entail Eclipse figuring out where the intended word boundaries are in a sequence of characters, and that is hard to get right.

If you look at these, they are all either unlikely to be needed much, or too hard to do properly. Hence, it doesn't surprise me that they are not supported by the standard Eclipse codebase.


Pressing Alt+Shift+R gives you all the power to refactor your variable name to your liking. AFAIK, there is no tool or shortcut that does just the capitalizing.


No. You'll have to use the standard rename refactoring and retype the variable name in capital letters.

Capitalizing variable names should be limited to those cases, where we change a class attribute to a "constant", and this doesn't happen that often...

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号