To create a new variable based on the selected expression, initialize it with the expression, and replace all occurrences of the expression with the variable, just press &shortcut:IntroduceVariable; (Refactor | Introduce Variable) and then choose a name for the new variable.