Skip to article
Documentation

Semantic rename across Elixir code

Rename modules, functions, protocols, callbacks, types, and bindings with a usage preview.

On this page

Rename a function by arity#

Use the order workshop. Put the caret on total in its declaration and invoke Refactor → Rename (usually Shift+F6). Enter line_total, without /2, and inspect the preview.

@spec total(non_neg_integer(), non_neg_integer()) :: non_neg_integer()
def total(price, quantity), do: price * quantity

# Call sites
OrderWorkshop.total(125, 3)
&OrderWorkshop.total/2

Review the declaration, spec, direct calls, and capture. In larger projects, supported literal apply and MFA tuples can also reference the function. A dynamically chosen atom cannot always be resolved safely, so search application-specific dispatch tables too.

Rename a module or alias target#

For modules, enter the full new module name. An alias with an explicit as: label can retain that local label while its target changes. Renaming the module does not move its source file; use Move Module when you intend both a new location and namespace.

Grouped aliases need care when moving a member to another namespace. Expand them into individual aliases if the operation reports a namespace conflict instead of forcing a text replacement.

Contracts and binding scope#

Native rename also covers named types, module attributes, variables, parameters, guards, macros, callbacks, and protocol functions. For a behaviour or protocol function, inspect implementations and dispatch usages in the preview. Renaming a local binding should change references to that binding, not every variable with the same spelling in another function.

TargetNew-name input
Function/macro/callback/typeIdentifier only, without arity
AttributeIdentifier without @
ModuleFull module name
Local variable/parameterNew binding name

Validate the change#

Read conflicts before applying. Compile and run focused tests afterward, then inspect the diff for generated code or dynamic dispatch that needs manual review. The operation supports Undo/Redo, making a small, isolated rename easier to assess than a large batch of unrelated edits.

Manual for version 2026.1.15 · Reviewed