WebStorm limits the refactoring scope to the current file only

EDIT: here is a link to my question [ https://youtrack.jetbrains.com/issue/WEB-21956 ]

Is it possible to limit the refactoring area of ​​WebStorm to the file in which you issued refactoring (by default)?

In this case, I have a file that I am editing, and I want to reorganize (rename) one variable. Then WebStorm will search all the files of the entire project. I searched this online resource and I can only find scope restrictions for specific folders. I hope that I should not create features for each file.

PS I found this related question ( https://stackoverflow.com/questions/33197566/pycharm-limit-refactor-renaming-to-current-file ). Although I can not comment on this, because I do not yet have a reputation of 50 (for shame). Most likely, if it is not in PyCharm, it is not in WebStorm (they share the code), so this is a more double check. If it turns out that this is actually not the case, I will add a link to the function request, I will send a message to WebStorm questions.

+5
source share
1 answer

As with WebStorm 2016.1.3, it is not possible to change the default behavior of Rename Refactoring . Only options are available for renaming within a limited area , in which case you can enable or disable the mode in place ( see documents ).

Here are two possible workflows. I will give instructions using the PC shortcuts, but you can achieve the same through the context menus.


Find and replace

  • Move the cursor to the character you want to rename
  • Select a word with Ctrl + W
  • Open the Replace dialog with Ctrl + R
  • Press Tab and enter a new name
  • Alt + P to replace the current occurrence or Alt + A to replace all occurrences

Rename a refactoring tool

  • Open the Renaming Restyling tool with Shift + F6
  • Enter a new name
  • Adjust the filters for Search in comments and strings and for Search for text occurrences (default)
  • Refactoring Preview ( Alt + P )
  • The Find Refactoring Preview panel ( Alt + 3 ) Find Refactoring Preview , listing all the occurrences found.
  • In this list you can choose which files will be refactored; for example, you can exclude all files by clicking Delete in the parent group and then clicking Insert only in the target file

In this (stupid) example, I rename require to require2 . Found several cases. I excluded all of them, excluding the main group, and then included only one file. I could exclude the rest of the groups or select all with Ctrl + A and then Delete to exclude.

refactor renaming example


see also

+5
source

Source: https://habr.com/ru/post/1247102/


All Articles