Extract Variable refactoring
The Extract Variable refactoring wraps the selected expression into a variable. It adds a new variable declaration and uses the expression as an initializer. Select an expression and press &shortcut:IntroduceVariable; (Refactor | Extract/Introduce | Variable).
Then type the name of the variable or select it from the list of suggestions:
