Awesome
RefactorEx
RefactorEx is a powerful Visual Studio Code extension that simplifies and accelerates code refactoring for Elixir projects. It introduces intuitive code actions to help you refactor Elixir code efficiently and confidently.
With RefactorEx, you can perform common refactorings like extracting functions, renaming variables, and more — all within a few clicks.
Available refactorings
How to use each refactoring
Alias: expand aliases
▲ top
<br>
Alias: extract alias
| |
---|
Description | Extract the module full name into an alias and use it |
Target | Selection of module full name |
Inverse of | Inline alias |
Example | |
▲ top
<br>
Alias: inline alias
| |
---|
Description | Replace the alias usage by the module full name |
Target | Selection of alias usage |
Inverse of | Extract alias |
Notes | 1. alias must be declared on the same module <br> 2. alias declaration will not be removed |
Example | |
▲ top
<br>
Alias: merge aliases
| |
---|
Description | Merge the group of aliases into a nested alias |
Target | Selection of two or more mergeable aliases |
Inverse of | Expand aliases |
Example | |
▲ top
<br>
Alias: sort nested aliases
| |
---|
Description | Sort all nested aliases alphabetically |
Target | Line of alias with unsorted nested aliases |
Example | |
▲ top
<br>
Constant: extract constant
▲ top
<br>
Constant: inline constant
| |
---|
Description | Replace a constant usage by its value |
Target | Selection of constant |
Inverse of | Extract constant |
Notes | 1. constant must be declared on the same module <br> 2. constant declaration will not be removed |
Example | |
▲ top
<br>
Constant: rename constant
▲ top
<br>
Function: collapse anonymous function
▲ top
<br>
Function: extract anonymous function
▲ top
<br>
Function: expand anonymous function
▲ top
<br>
Function: extract function
▲ top
<br>
Function: inline function
▲ top
<br>
Function: rename function
| |
---|
Description | Replace the name of function in all its calls |
Target | Selection of (or cursor over) function name |
Read more | Catalog of Elixir refactorings |
Notes | ⚠️ Renaming a public function only affects the current file |
Example | |
▲ top
<br>
Function: underscore unused args
| |
---|
Description | Places a _ in front of args not used |
Target | Line of function definition with unused args |
Example | |
▲ top
<br>
Function: use keyword syntax
| |
---|
Description | Rewrite the function using keyword syntax |
Target | Line of function definition using regular syntax |
Inverse of | Use regular syntax |
Notes | function body must have a single statement |
Example | |
▲ top
<br>
Function: use regular syntax
| |
---|
Description | Rewrite the function using regular syntax |
Target | Line of function definition using keyword syntax |
Inverse of | Use keyword syntax |
Example | |
▲ top
<br>
Guard: extract guard
| |
---|
Description | Extract a when statement into a guard |
Target | Selection of when statement or part of one |
Inverse of | Inline guard |
Example | |
▲ top
<br>
Guard: inline guard
| |
---|
Description | Replace a guard call by its when statement |
Target | Selection of guard call |
Inverse of | Extract guard |
Notes | 1. guard must be defined on the same module <br> 2. guard definition will not be removed |
Example | |
▲ top
<br>
Guard: rename guard
| |
---|
Description | Replace the name of guard in all its calls |
Target | Selection of (or cursor over) guard name |
Read more | Catalog of Elixir refactorings |
Notes | ⚠️ Renaming a public guard only affects the current file |
Example | |
▲ top
<br>
If else: use keyword syntax
| |
---|
Description | Rewrite the if else using keyword syntax |
Target | Line of if using regular syntax |
Inverse of | Use regular syntax |
Notes | Clauses must have a single statement |
Example | |
▲ top
<br>
If else: use regular syntax
| |
---|
Description | Rewrite the if else using regular syntax |
Target | Line of if using keyword syntax |
Inverse of | Use keyword syntax |
Example | |
▲ top
<br>
Pipeline: introduce IO.inspect
| |
---|
Description | Pipe a piece of code into an IO.inspect |
Target | Selection of any code |
Inverse of | Remove IO.inspect |
Example | |
▲ top
<br>
Pipeline: introduce pipe
| |
---|
Description | Pipe the first arg into function call or case condition |
Target | Line of function call or case condition |
Inverse of | Remove pipe |
Example | |
▲ top
<br>
Pipeline: remove IO.inspect
▲ top
<br>
Pipeline: remove pipe
▲ top
<br>
Variable: extract variable
▲ top
<br>
Variable: inline variable
▲ top
<br>
Variable: rename variable
| |
---|
Description | Replace the name of variable in all its usages |
Target | Selection of (or cursor over) variable assignment |
Read more | Catalog of Elixir refactorings |
Example | |
▲ top
<br>