2019-10-09 14:04:45 +03:00
|
|
|
## Mastering the IDE: Rename
|
|
|
|
|
2020-10-11 21:40:34 +03:00
|
|
|
The IDE simplifies many common actions. For example, suppose you want to rename
|
|
|
|
an identifier. Inventing a good name is difficult, so it's often an iterative
|
|
|
|
process. After using a function, for example, you might think up a better name
|
|
|
|
for it.
|
2019-10-09 14:04:45 +03:00
|
|
|
|
|
|
|
<span class="control">`Find`</span> and <span class="control">`Replace`</span>
|
2020-10-11 21:40:34 +03:00
|
|
|
may lead to unexpected results, because the name might appear in different
|
|
|
|
contexts, for example inside strings or comments. In the code example you can
|
|
|
|
see `answer` both as a name for a `val` and as a part of a string literal. It's
|
|
|
|
even more complicated when renaming a function because that function might be
|
|
|
|
used in many files.
|
2019-10-09 14:04:45 +03:00
|
|
|
|
2020-10-11 21:40:34 +03:00
|
|
|
The IDE allows you to rename a declaration automatically. Put the caret on the
|
|
|
|
`val` name and press <span class="shortcut">&shortcut:RenameElement;</span>.
|
|
|
|
You can also choose <span class="control">`Refactor`</span> from the
|
|
|
|
application menu, then choose <span class="control">`Rename`</span>.
|
2019-10-09 14:04:45 +03:00
|
|
|
|
2021-07-20 14:01:22 +03:00
|
|
|
Rename the `val` name to `result` without changing the word "answer" in the
|
|
|
|
string literal. The string should become: "The answer is $result".
|