Replace matches using an interpreted script
mainFor complex replacements, you can use the Swap Replacement Interpreter action to switch to a script engine like lua or vimscript. This allows you to write logic that executes for every match.
Lua Interpreter:
- Write the body of a Lua function in the
Replace:input. - Use the
matchvariable to refer to the current match. - You must
returnthe value intended as the replacement. - astgrep engine users: You can access meta variables via the
varstable (e.g.,$Aisvars.A,$$$ARGSisvars.ARGS).