Creating Code Snippets
Create a Code Snippet using the following steps:- Enter your code in an empty notebook cell.
- Click Create a New Code Snippet in the cell toolbar.
- Enter a name for your code snippet.
-
Select a project to house your snippet.
If you don’t have any projects, a new project with the code snippet name as the title will be created.
- Click Create Code Snippet.
.py
file with the code snippet’s name appears in the project and is ready to be used across your notebooks. Save the project by pushing your project to Anaconda.com to share your snippets across devices and software.
Sharing a snippet
You can share a snippet with others in your organization by sharing the project that contains the snippet.Inserting snippets in a notebook
When you’re ready to use a saved snippet, insert it in a notebook using the following steps:- Open Anaconda Toolbox.
- Under Code Snippets, select Manage Code Snippets. Alternatively, under Projects, select Manage Projects.
-
You can now insert your snippet in one of two ways:
- Select a cell in the notebook where you’d like to insert the code.
- Click Insert code snippet in notebook beside the code snippet.
Editing a snippet
To edit a snippet, you must make changes to the snippet directly in the Anaconda Toolbox extension.- Open Anaconda Toolbox.
- Under Code Snippets, select Manage Code Snippets. Alternatively, under Projects, select Manage Projects.
- Double-click the snippet’s
.py
file to open the file. - Adjust your snippet.
- To save your file changes, go to File, then select Save Python File.