Translating Terminology: Edit All in Scope (Xcode) and Refactor->Rename (Android)


When you want to rename an item (e.g. variable, constant, function) rather change every instance manually or using find and replace you can use what is known as Edit All in Scope in Xcode or Rename in Android Studio. It is then simply a case of writing a new name and all instances of that name will be changed.

Note: Renaming (which includes instances outside the current file) also exists in Xcode, as well as Android Studio, but not in the context of Swift, see note in section below.

Edit All in Scope (Xcode)

With the cursor on the name do one of the following:

Shortcut: cmd + ctrl + e
Longcut: right-click on a variable name and select "Edit All in Scope"
Alternative: go to the menu bar and choose Editor -> Edit All in Scope

Note: Currently using Swift it is not possible to Refactor across your entire project in Xcode. But when writing Objective-C it is (still) possible using Refactor -> Rename either from a right-click or the Edit menu on the menubar.

Refactor -> Rename (Android Studio)

With the cursor on the name do one of the following:

Shortcut: shift + F6
Longcut: right-click on variable name and select Refactor... followed by Rename...
Alternative: go to the menu bar and choose Refactor -> Rename

Note: Renaming occurs across your entire project when changing things like method and class names but not for elements such as repeated property names that are the same by coincidence. The latter only change when one is a proper reference to the other.

Acknowledgements

Thanks to @krzyzanowskim for the prod on twitter that set me off researching Edit All in Scope.


Endorse on Coderwall

Comments