This extension allows you to create, save, and use Python function definitions in your workspace. You can define functions in the editor and trigger their insertion by typing !<function_name>, which will save the function definitions in a functions.json file. Once saved, you can easily autocomplete
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
This extension allows you to create, save, and use Python function definitions in your workspace. You can define functions in the editor and trigger their insertion by typing !<function_name>, which will save the function definitions in a functions.json file. Once saved, you can easily autocomplete and insert these functions back into your code. Execute the command that follows the pattern !<function_name> --d followed by Space to remove the function data from functions.json.
Features
Save Functions to functions.json: Define Python functions directly in the editor using standard Python syntax, and then use !<function_name> to save them to a functions.json file.
Autocomplete for Saved Functions: Once the functions are saved, you can get autocomplete suggestions for the function names, and the code for the function will be inserted into your file automatically when you select a suggestion.
Trigger Function Save with !<function_name>: When typing !<function_name>, the extension will detect the function name, search for the function in the editor, and save the function code into the functions.json file.
JSON Structure: Function data is saved in the functions.json file with a clear structure, including the function name (label) and the function code (code).
Execute the command that follows the pattern !<function_name> --d followed by Space to remove the function data from functions.json.
Function Definition Example
In the editor, type the function definition as follows:
def fnc_test(a, b):
return a + b
To save the function fnc_test, type !fnc_test and press Ctrl+Space (Windows, Linux, macOS) to see a list of Markdown snippets, select fnc_test or press Space the function will be saved in functions.json.
Autocomplete Example
After saving the function in functions.json, typing the function name (e.g., fnc_test) followed by Ctrl+Space will provide an autocomplete suggestion.
Select the suggestion, and the function will be inserted into your code at the cursor location.
Function Removal Example
Execute the command that follows the pattern !<function_name> --d followed by Space.
Tip: This extension makes it easy to store and reuse function definitions, improving your productivity while working with Python code.
Requirements
Node.js: Ensure you have Node.js installed on your machine, as it's required for the extension to run.
Python: The extension supports Python code saving and insertion.
Extension Settings
This extension currently does not add any custom settings to the VS Code configuration. However, the functionality can be controlled through the standard VS Code interface.
Known Issues
Function definitions must be written correctly in Python syntax for them to be saved. Incorrect function definitions may not be detected and saved properly.
If the functions.json file is manually edited while the extension is running, the changes may not reflect until the editor is reloaded or the file is saved again.
Release Notes
1.0.2
Initial release of the extension.
Implemented function saving to functions.json.
Added autocomplete for saved functions with !<function_name>.
1.0.3
Bug Patch
Working with Markdown
You can author your README using Visual Studio Code. Here are some useful editor keyboard shortcuts:
Split the editor (Cmd+\ on macOS or Ctrl+\ on Windows and Linux)
Toggle preview (Shift+Cmd+V on macOS or Shift+Ctrl+V on Windows and Linux)
Press Ctrl+Space (Windows, Linux, macOS) to see a list of Markdown snippets