Reputation: 8160
So I've been working on a relatively large project by myself, and I've come to realise that some of the variable names earlier on were.. less than ideal.
But how does one change variable names in a project easily? Is there such a tool that can go through a project directory, parse all the files, and then replace the variable names to the desired one? It has to be smart enough to understand the language I imagine.
I was thinking of using regexp (sed/awk on linux?) tools to just replace the variable name, but there were many times where my particular variable is also included as a part of strings.
There's also the issue about changing stuff on a c++ namespace, because there is actually two classes in my project that share the same name, but are in different namespaces.
I remember visual studio being able to do this, but what's the safest and most elegant way to do this on linux?
Upvotes: 7
Views: 3974
Reputation: 264631
Safest (non automated way) way:
Tongue only half in cheek. :-)
Upvotes: 5
Reputation: 104698
use private variables, rename the variable and the obvious uses, correct the compiler errors.
Upvotes: 0
Reputation: 40887
$400 a f'n copy, but here you go: http://www.xref.sk/xrefactory/download.html
I've of course never used it.
Upvotes: 1
Reputation: 8004
I know C# and visual studio has a great variable changer, but does it work through all the documents im not sure. I know when you change a variable in C# it pops up in the beside the Variable text. Change All
However you may be stuck with the only option. Change variables and see where the compiler goes wrong. However its not ideal, but may be your only choice
Upvotes: 0
Reputation: 39790
I remember visual stuio being able to do this, but what's the safest and most elegant way to do this on linux?
You can do pretty much what you used to do in visual studio in Eclipse using the re-factoring tools, which is available for Linux.
Upvotes: 1
Reputation: 210725
It's called refactoring, but I don't remember if there's a great way to do it in C++ -- I think maybe Eclipse C++ had it; might be worth taking a look.
Upvotes: 6