Editing
Keep your library of saved code snippets up-to-date easily with the seamless editing process between Visual Studio and the Pieces for Visual Studio Extension.
How to Edit Snippets
To modify code you’ve saved to your personal repository, you can use the Pieces Drive view in Visual Code.
If you don’t have it open, use the command palette shortcut ctrl+shift+p
and type Pieces Drive, then click it or press enter
to open the view.
Locating a Snippet
Inside the Pieces Drive view, you can select the snippet you want to edit from the scrollable list of saved materials, or use the Search Bar to enter a query and locate your desired snippet.
Open the Snippet
To start editing your saved material from your repository, click the Pencil Icon. Hovering over this icon reveals a Edit Selected Material
+ ctrl+e
tooltip.
Edit the Snippet
Once you click the Pencil Icon, your saved code will open in a new tab, and you’ll automatically be redirected to that tab. Simply make your changes as needed.
Save the Snippet
After making the desired changes to the code snippet, use ctrl+s
to save the snippet, after which you will be returned to your active file.
You’ll see a success message at the top of the active file indicating that your changes have been made successfully.
Material Management Actions
From within the Pieces Drive view, you can click the three vertical dots to review a Quick Actions
tab that shows available metadata that you can view or directly adjust for that snippet.
You can view the table below for a comprehensive list of available actions.
| Set your own custom snippet classification. |
---|---|
| Change the name (title) of the material as it appears in your Pieces Drive. |
| Create a duplicate of the saved material—non-modified or modified to be more performant, readable, as a template, or in another language. |
| View, add or remove related resources which provide additional context to the snippet. |
| Add or remove tags to the snippet’s metadata. |
| Generate or copy a shareable link for the saved material. |
| View or edit the automatically generated description for that saved code. |
| Add associated files and directories to the material. |
| Manage related code authors or coworkers. |
| Manually add or remove, if not automatically generated, a sensitive information tag to the snippet. |
| Remove this saved material from Pieces Drive. |
Additional Tools while Editing
When you edit a saved snippet, you are opening a new file in Visual Studio to make those edits—which means that other Pieces functionalities, like functionalities provided by Pieces Copilot and Pieces Drive, are completely available to you.
For example, when editing a snippet, right-clicking selected code will present you with the same toolbar and Pieces-related options (like Save Current Selection to Pieces
or Share Current Selection
).
This makes it easy to modify your saved code with the power that the Pieces for Visual Studio Extension gives you.