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.

1

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.

2

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.

3

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.

4

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.


Reclassify

Set your own custom snippet classification.

Rename

Change the name (title) of the material as it appears in your Pieces Drive.

Duplicate

Create a duplicate of the saved material—non-modified or modified to be more performant, readable, as a template, or in another language.

Related Links

View, add or remove related resources which provide additional context to the snippet.

Tags

Add or remove tags to the snippet’s metadata.

Shareable Link

Generate or copy a shareable link for the saved material.

Annotations

View or edit the automatically generated description for that saved code.

Anchors

Add associated files and directories to the material.

Related People

Manage related code authors or coworkers.

Sensitive Information

Manually add or remove, if not automatically generated, a sensitive information tag to the snippet.

Delete Piece

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.

Updated on