Sharing Snippets

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

With this feature, you can generate a unique, shareable link for any snippet directly from the VS Code tool window interface.


What Information Gets Shared

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

How to Share a Saved Snippet

There are 3 ways to share saved snippets—by using the tool menu, keyboard shortcuts, or by right-clicking on previously-saved snippets within the Pieces Drive.

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.

via Keyboard Shortcut

You can share snippets using the ⌘+shift+i (macOS) or ctrl+shift+i (Windows/Linux) after highlighting your desired lines of code in 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 Pieces Drive.

1

Open the Pieces Drive

Open the Pieces Drive via the Pieces Drive icon in the VS Code sidebar

2

Share the Snippet

After finding the snippet you want to share, right-click it and choose Generate Shareable Link from the options.

3

Wait for the Link and Copy

After generating the link, a new modal will appear, wait for the snippet to be shared with an automatically generated link or manually copy the link from the modal

If you have generated a link for that snippet previously, the More Actions menu options will automatically adjust to include 3 new actions:

  • Open in Browser: Opens the existing shareable link in your desired browser.

  • Refresh Link: Regenerates the link—this is important if a snippet has been edited or updated, as a new link will be required to contain the new changes.

  • Revoke Link: Revokes the shareable link so that anyone with the existing link to that snippet will be barred from future access.

Enriched Sharing Experience

When you Share a snippet, it’s not just the code that’s included. The snippet comes with 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.

Sensitive Information Watchdog

The Share feature does more than just 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—that way, you can make an informed decision about sharing your code.

Updated on