Sharing Snippets

The Share feature in the Pieces for Visual Studio Extension makes sharing your saved code snippets with colleagues, teams, or the wider development community easy.


Sharing Snippets with Pieces

With this feature, you can generate a unique, shareable link for any saved material directly from your active file in Visual Studio or with a shortcut.

How to Share a Snippet

There are two ways to share saved snippets within Visual Studio: using the right-click tool menu or keyboard shortcuts.

This link can easily be shared via email, Discord, Slack, or other platforms. The recipient can view the snippet without needing to have a Pieces account.

via Right-Click Menu

Shareable Pieces links for your code snippets can be generated by right-clicking a portion of selected code, hovering over the Pieces item in the pop-up menu, then clicking Share Current Selection.

via Keyboard Shortcut

You can generate shareable links for your code snippets using the alt+M, L keyboard shortcut after highlighting the desired code within your active file.

If you save a material, but didn’t generate a shareable link at the time, no problem. You can still generate a shareable link (or copy, regenerate, or delete the existing link) from the Quick Menu within the Pieces Drive view.

1

Open the Pieces Drive View

Open the Pieces Drive view and find the saved material for which you want to generate a shareable link.

2

Launch the Quick Menu

Once you’ve located the saved material you want to share, click the three vertical dots to open the Quick Menu.

3

Generate the Shareable Link

After the quick menu opens, you’ll see a section titled Shareable Link. Click Generate Shareable Link to generate it and automatically copy it to your clipboard.

You can also generate the link using the right-click menu if you edit the saved material. This opens the code in an independent file. To do this, right-click the selected piece, hover over Pieces, and click Share Current Selection.

4

Share the Saved Material

Your shareable link has now been copied to your clipboard, so you can share it with anyone—no need for them to have a Pieces Account.

Enriched Sharing Experience

When you Share a snippet, it’s not just the code included. The snippet has additional metadata to provide context—you can read more about that here.

  • Snippet Type: Identify the language or framework, such as Python or React.

  • Tags: Useful keywords for quick categorization.

  • Description: A short summary of what the snippet does.

  • Related Links: Helpful resources or documentation tied to the snippet.

  • Author Information: A record of who created the snippet.

What Information Gets Shared

When a snippet is saved to the Pieces Drive, the code is enriched with valuable information such as related people, links, annotations, tags, and an automatically-generated description.

Sensitive Information Watchdog

The Share feature does more than allow you to effectively share snippets across your entire team and other communities, though.

You'll see a section titled Sensitive Information:

Our in-house ML model scans snippets for potentially sensitive information, like API keys or passwords, and alerts you so that you can make an informed decision before sharing the snippet.  

The scan happens locally using on-device machine learning models before the snippet is uploaded to the cloud for sharing. This allows you to make an informed decision about sharing your code.

Updated on