Extract/Introduce variable

Last modified: 08 October 2024

If you come across an expression that is hard to understand or it is duplicated in several places throughout your code, the Extract Variable refactoring can help you deal with those problems placing the result of such expression or its part into a separate variable that is less complex and easier to understand. Plus, it reduces the code duplication.

By default, this extract refactoring will be applied in the editor via in-line controls. To change your settings to apply the refactoring via a modal, open the Settings dialog () , go to Editor | Code Editing, and in the Refactorings area select In modal dialogs.