Change the name throughout the app?

Hi all,

Is there a way to change the name of a component/variable throughout the app, for example, If I have a label called self.lable1 and this label is repeated in my app multiple times in different places, is it possible to change it in one place and this change applied automatically throughout the app?

Thank you.

I do this :

  1. do a global search (shift-control-F)
  2. clicking each entry in the result list takes you to the instance so you can change it
  3. shift-control-F again takes you back to the previous results list with the last clicked item still highlighted so you can step to the next one

It’s not perfect but it is the best I’ve found so far.

2 Likes

This is where I usually resort to Git, to get a local copy of the files. Advantages :

  1. This allows me to search-and-replace into the forms (.yaml files), as well as the Python code.
  2. I have many more choices of source-code-specific tools. (For example. Notepad++ does not let me [dis]approve individual changes, on multi-file search and replace, but other tools do.)

The disadvantage: it’s Git. If you’ve already hurdled Git’s learning curve, great. If not…

2 Likes

For simple cases @david.wylie solution works.

For more complex cases, like @p.colbert, I use Git to clone the repository to my computer, then I use PyCharm to refactor.

Using ctrl+shift+F in PyCharm you will find text in any source module and in all the yaml files (better than the IDE). I try no to modify the yaml files, but it’s good to be able to search through them.

Using shift+F6 PyCharm will find all the places where a variable has been used and rename it. Much better than a text replace, which will replace any text without knowing if it’s inside a comment, a string or part of a longer variable name.

4 Likes

Thank you all :grinning: