Hello,
It should be nice I may use this feature because I have to apply coding standards upon variables, functions etc...
What I would like : Select a variable named "layer_id" and renamed it "AGS_LayerId" for example everywhere in my code. If it's a local variable, renamed it only into the appropriate function.
Is there anyway to do that efficiency with Code::Blocks ?
Thanks
Have a nice day.
Stephane
Did you try the "Replace in Files" function under the "Search" menu?
Ringo
Interesting idea, something I'd wish to have too sometimes. Unluckily the "only inside a function" thing means that there would have to be some considerable AS built into Code::Blocks, which currently isn't the case.
So... yes, "replace in files" sure works, but it's not precisely what you want.
Yes this would be very nice to have. In MS visual studio C# it can be done with refactor-->rename. The MS ide knows which vars to change and which not. Not an easy thing to implement (robustly)
Jan
Quote from: thomas on September 12, 2008, 12:01:53 PM
Interesting idea, something I'd wish to have too sometimes. Unluckily the "only inside a function" thing means that there would have to be some considerable AS built into Code::Blocks, which currently isn't the case.
So... yes, "replace in files" sure works, but it's not precisely what you want.
I don't get this ... what is it exactly you would like to do? If I want to change "MyVar" to "SomeOtherVar", then replace-in-files works perfectly fine for me. If it's a really *really* complicated search-and-replace, I just load up an external editor that specializes in such things and do it there. It's such a rare thing, I don't really mind doing it.
What am I not understanding?
Ringo
Quote from: rcoll on September 14, 2008, 06:47:58 AM
What am I not understanding?
Refactor->Rename means that variable scoping is taken into account, it is the most complicated thing.
Suppose you have i defined for two loops in two different functions.
Right clicking on i in a function and make Refactor->Rename on it could replace i by index for example only in the appropriate method/function, whereas the replace in files would replace any i whole word instances in all files.
Dje
Quote from: dje on September 14, 2008, 11:04:50 AM
Quote from: rcoll on September 14, 2008, 06:47:58 AM
What am I not understanding?
Refactor->Rename means that variable scoping is taken into account, it is the most complicated thing.
Suppose you have i defined for two loops in two different functions.
Right clicking on i in a function and make Refactor->Rename on it could replace i by index for example only in the appropriate method/function, whereas the replace in files would replace any i whole word instances in all files.
Dje
Ah ... got it. Thanks for the (very good) explanation. I can now see where this Refactor-Rename might be usefull; although, for my uses, I would still use rename-in-files and just change "Myclass->MyVar" to "MyClass->SomeOtherVar" (but then most of my software is pretty simple and not that compilcated).
Ringo