Tip: If you are using vsCode here is an easy way to do multi select change

In the videos, we often copy and paste blocks of code and rename some portion of the code If you are using VS Code you can use the multiselect feature. Basically you can highlight the portion you wish to change, then press CTRL-D to select the next occurrence of the selection. Then just type what you would like to change it to.
IE: lets say we have the following code that we just copied and pasted, but we want to change Unit to Building:

        Unit.ServerOnUnitSpawned += ServerHandleUnitSpawned;
        Unit.ServerOnUnitDespawned += ServerHandleUnitDespawned;

Simply highlight the first occurrence of Unit, press Ctrl-D (x6) to highlight all occurrences of Unit, then type Building. Presto they are all changed. This works great when you need to unsubscribe to events. Just copy where you subscribed, paste where you need to unsubscribe, highlight the +, press Ctrl-D(as many times as needed) then press -

NOTE: If you are renaming a method or field, it is better to use the F2 so that it is renamed everywhere in your project.

Hope this helps.

4 Likes

Great tip Timothy, thanks for sharing!

Good tip.

For JetBrains Rider users with the default key bindings, you can do the same multi-selection thing with Alt + J (as many times as necessary), and Shift + F6 to rename a method or field throughout your project.

2 Likes

Privacy & Terms