"Code Transformer" is a Visual Studio Code extension that allows you to transform or process code by executing custom JavaScript expressions or preset expressions.
No configuration is required. Simply use the transform code extension
command to manually input an expression.
The parameters that can be used in the expression are:
s
: Current line of textl
: Current line numberf
: Built-in function object
- Select the line of text you want to process.
- Open the command palette and execute the
transform code extension
command. - In the input box that appears, type
s.split('').reverse().join('')
. - After execution, the selected line of text will be reversed.
You can configure built-in functions in the settings panel to call these functions in expressions.
- Open settings and navigate to the Code Transformer settings.
- In the "Built-in Functions" section, add a new function, for example:
[
{
"name": "toSnakeCase",
"code": "(str) => { return str.replace(/([A-Z])/g, '_$1').toLowerCase(); }"
}
]
- Save the settings.
- Now you can use
f.toSnakeCase(s)
in the input box for thetransform code extension
command or in preset expressions.
You can configure preset expressions in the settings panel for quick selection and execution.
- Open settings and navigate to the Code Transformer settings.
- In the "Preset Expressions" section, add a new expression, for example:
[
{
"name": "toSnakeCaseExp",
"code": "f.toSnakeCase(s)"
}
]
- Save the settings.
- Now you can open the list of preset expressions (quickPick) via the
transform pick extension
command and choose this preset expression for execution.
Licensed under the MIT License.
For any questions or suggestions, please contact us.