Refactoring
Safe rename refactoring with automatic updates
The plugin supports safe rename refactoring that automatically updates all references to a symbol.
Rename Refactoring
Section titled “Rename Refactoring”Rename any symbol and have all its usages updated automatically:
| Action | macOS | Windows/Linux |
|---|---|---|
| Rename | Shift+F6 | Shift+F6 |
What Can Be Renamed
Section titled “What Can Be Renamed”- Templates: All component instantiations will be updated
- Functions: All function calls will be updated
- Signals: All references within the template will be updated
- Variables: All uses of the variable will be updated
- Components: All accesses to the component will be updated
Example
Section titled “Example”Before:
template OriginalName() { signal input value; signal output doubled; doubled <== value * 2;}
template Consumer() { component instance = OriginalName(); instance.value <== x;}After renaming OriginalName to Doubler:
template Doubler() { signal input value; signal output doubled; doubled <== value * 2;}
template Consumer() { component instance = Doubler(); instance.value <== x;}How to Use
Section titled “How to Use”- Position cursor on the symbol you want to rename
- Press
Shift+F6to start the rename - Type the new name - you’ll see a preview of all changes
- Press Enter to apply, or Escape to cancel
In-Place Rename
Section titled “In-Place Rename”For simple renames within a single file, the plugin uses in-place rename:
- The symbol becomes editable directly in the editor
- All occurrences are highlighted
- As you type, all occurrences update in real-time
- Press Enter to confirm or Escape to cancel
Name Validation
Section titled “Name Validation”The plugin validates new names to ensure they’re valid Circom identifiers:
Valid Names Must:
Section titled “Valid Names Must:”- Start with a letter, underscore (
_), or dollar sign ($) - Contain only letters, digits, underscores, or dollar signs
Reserved Words
Section titled “Reserved Words”You cannot rename a symbol to a reserved keyword:
pragma, circom, include, template, function, component, main, public, signal, input, output, var, if, else, for, while, do, log, assert, return, parallel, custom, bus
Best Practices
Section titled “Best Practices”Rename One Thing at a Time
Section titled “Rename One Thing at a Time”Make one rename, verify it works, then proceed to the next. This makes it easier to revert if something goes wrong.
Use Descriptive Names
Section titled “Use Descriptive Names”Take the opportunity when renaming to choose clear, descriptive names:
h→hashertmp→intermediateHashx→inputValue
Check the Preview
Section titled “Check the Preview”Always review the preview of changes before confirming, especially for:
- Templates used across multiple files
- Commonly used function names
- Signals with generic names