-1

I have a class with about 50 fields. They are named roughly like this:

config__write_better_code

I want them to look like this instead and not have to rename them all manually:

Config$WriteBetterCode

I'm using eclipse, but anything that can rename the code is welcome.

Diemex
  • 821
  • 2
  • 12
  • 19
  • 2
    How can we tell you... You have a design problem. – Denys Séguret Feb 12 '13 at 21:19
  • 1
    50 fields. Will take only a few minutes to do it by hand. – MrSmith42 Feb 12 '13 at 21:19
  • 4
    "$" is reserved: "The $ character should be used only in mechanically generated source code or, rarely, to access pre-existing names on legacy systems." – Hot Licks Feb 12 '13 at 21:21
  • 1
    Use the Refactor->Rename feature in eclipse for each variable. – DwB Feb 12 '13 at 21:23
  • Just use alt+shift+r 50 times. Shouldn't take too long. (that is the shortcut to rename variables in Eclipse, it will also modify wherever it is used). – Simon Verhoeven Feb 12 '13 at 21:24
  • I was thinking of using regexes, but they can't save the character and make it uppercase. I need some character that doesn't get used normally in variableNames and so I just took the dollar sign, my pc won't explode now will it? – Diemex Feb 12 '13 at 21:39

2 Answers2

2

click on the variable name.

1:press [alt] + [shift] + [R]

2:enter the new name.

3:press [enter] to confirm.

-->all instances of this variable will be renamed.

Simulant
  • 19,190
  • 8
  • 63
  • 98
  • Thx, but I know how to refactor. I was thinking more of a regex based way, because all variables are named by the same pattern. – Diemex Feb 12 '13 at 21:45
1

The AnyEdit Eclipse plugin might help you (in combination with the rename feature of eclipse):

http://andrei.gmxhome.de/anyedit/

Convert Camel <-> Underscores

Auto-convert variable names from/to "camel" notation, like thisIsMyFieldName <-> this_is_my_field_name

Thomas Traude
  • 840
  • 7
  • 17
  • Just checked, and 1) It only renames one line, not all variable usages 2) It only renames 1 variable, and only if selected – Andrey Oct 20 '16 at 08:37