RefactorEx is a powerful editor plugin 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.
You can check all supported editors in our installation guide.
Scope | Refactoring | Target | Command |
---|---|---|---|
alias |
Expand aliases | selection | refactor (ctrl +. ) |
alias |
Extract alias | selection | refactor (ctrl +. ) |
alias |
Inline alias | selection | refactor (ctrl +. ) |
alias |
Merge aliases | selection | refactor (ctrl +. ) |
alias |
Sort nested aliases | line | refactor (ctrl +. ) |
constant |
Extract constant | selection | refactor (ctrl +. ) |
constant |
Inline constant | selection | refactor (ctrl +. ) |
constant |
Rename constant | at symbol | rename (F2 ) |
function |
Expand anonymous function | selection | refactor (ctrl +. ) |
function |
Extract anonymous function | selection | refactor (ctrl +. ) |
function |
Extract function | selection | refactor (ctrl +. ) |
function |
Collapse anonymous function | selection | refactor (ctrl +. ) |
function |
Inline function | selection | refactor (ctrl +. ) |
function |
Rename function | at symbol | rename (F2 ) |
function |
Underscore unused args | line | refactor (ctrl +. ) |
function |
Use keyword syntax | line | refactor (ctrl +. ) |
function |
Use regular syntax | line | refactor (ctrl +. ) |
guard |
Extract guard | selection | refactor (ctrl +. ) |
guard |
Inline guard | selection | refactor (ctrl +. ) |
guard |
Rename guard | at symbol | rename (F2 ) |
if else |
Use keyword syntax | line | refactor (ctrl +. ) |
if else |
Use regular syntax | line | refactor (ctrl +. ) |
pipeline |
Introduce IO.inspect | selection | refactor (ctrl +. ) |
pipeline |
Introduce pipe | line | refactor (ctrl +. ) |
pipeline |
Remove IO.inspect | line | refactor (ctrl +. ) |
pipeline |
Remove pipe | line | refactor (ctrl +. ) |
variable |
Extract variable | selection | refactor (ctrl +. ) |
variable |
Inline variable | selection | refactor (ctrl +. ) |
variable |
Rename variable | at symbol | rename (F2 ) |
Description | Expand nested aliases to their full names |
Target | Selection of nested alias , group of nested aliases or alias with nesting |
Inverse of | Merge aliases |
Read more | Catalog of Elixir refactorings |
Example |
Description | Extract the module full name into an alias and use it |
Target | Selection of module full name |
Inverse of | Inline alias |
Example |
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 2. alias declaration will not be removed |
Example |
Description | Merge the group of aliases into a nested alias |
Target | Selection of two or more mergeable aliases |
Inverse of | Expand aliases |
Example |
Description | Sort all nested aliases alphabetically |
Target | Line of alias with unsorted nested aliases |
Example |
Description | Extract a piece of code into a constant |
Target | Selection of any code without variables |
Inverse of | Inline constant |
Read more | Catalog of Elixir refactorings |
Example |
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 2. constant declaration will not be removed |
Example |
Description | Replace the name of constant in all its usages |
Target | Cursor at constant definition or usage |
Read more | Catalog of Elixir refactorings |
Example |
Description | Collapse a fn function into a & function |
Target | Selection of fn function |
Inverse of | Expand anonymous function |
Example |
Description | Extract a & or fn function into a function |
Target | Selection of & or fn function |
Inverse of | Inline function |
Read more | Catalog of Elixir refactorings |
Example |
Description | Expand a & function into a fn function |
Target | Selection of & function |
Inverse of | Collapse anonymous function |
Example |
Description | Extract a piece of code into a function |
Target | Selection of any code |
Inverse of | Inline function |
Read more | Catalog of Elixir refactorings |
Example |
Description | Replace a function call by its body |
Target | Selection of function call |
Inverse of | Extract anonymous function, Extract function |
Read more | Catalog of Elixir refactorings |
Notes | 1. function must be defined on the same module 2. function definition will not be removed |
Example |
Description | Replace the name of function in all its calls |
Target | Cursor at function definition or usage |
Read more | Catalog of Elixir refactorings |
Notes | function only affects the current file |
Example |
Description | Places a _ in front of args not used |
Target | Line of function definition with unused args |
Example |
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 |
Description | Rewrite the function using regular syntax |
Target | Line of function definition using keyword syntax |
Inverse of | Use keyword syntax |
Example |
Description | Extract a when statement into a guard |
Target | Selection of when statement or part of one |
Inverse of | Inline guard |
Example |
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 2. guard definition will not be removed |
Example |
Description | Replace the name of guard in all its calls |
Target | Cursor at guard definition or usage |
Read more | Catalog of Elixir refactorings |
Notes | guard only affects the current file |
Example |
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 |
Description | Rewrite the if else using regular syntax |
Target | Line of if using keyword syntax |
Inverse of | Use keyword syntax |
Example |
Description | Pipe a piece of code into an IO.inspect |
Target | Selection of any code |
Inverse of | Remove IO.inspect |
Example |
Description | Pipe the first arg into function call or case condition |
Target | Line of function call or case condition |
Inverse of | Remove pipe |
Example |
Description | Remove IO.inspect call |
Target | Line of IO.inspect call |
Inverse of | Introduce IO.inspect |
Example |
Description | Remove |> from function call or case condition |
Target | Line of pipe (|> ) |
Inverse of | Introduce pipe |
Read more | Catalog of Elixir refactorings |
Example |
Description | Extract a piece of code into a variable |
Target | Selection of any code |
Inverse of | Inline variable |
Read more | Catalog of Elixir refactorings |
Example |
Description | Replace all usages of variable by its value |
Target | Selection of variable assignment |
Inverse of | Extract variable |
Read more | Catalog of Elixir refactorings |
Example |
Description | Replace the name of variable in all its usages |
Target | Cursor at variable definition |
Read more | Catalog of Elixir refactorings |
Example |