Saving

The Pieces for VS Code Extension provides several ways to save code snippets so your most useful code is always at hand.


Saving Snippets

There are two ways to save code with the Pieces for VS Code Extension—through the right-click menu, or by saving with hotkeys.

You can use this feature to save all kinds of useful code materials, like:

  • API endpoint definitions

  • Utility functions or commonly used helper methods

  • Code templates for starting new modules

  • Reusable logic for error handling or authentication

via Right-Click Menu

To capture useful code snippets via the right-click menu:

  1. Highlight the code you want to save

  2. Right-click on the highlighted code and hover on the Pieces option

  3. Select either Save Current Selection to Pieces or Save Active File to Pieces

via Keyboard Shortcuts

If you’re a developer who avoids using their cursor as much as possible, you can instantly save your selected code using keyboard shortcuts.

To do this:

  1. Highlight the code you want to save

  2. Use the ⌘+shift+v (macOS) or ctrl+shift+v (Windows/Linux) shortcut

via Copilot Chat

You can take any code block existing in your Copilot Chat and click Save to Pieces—like code generated by Pieces Copilot, code blocks you added as context that weren’t saved as individual snippets, and any other kind of code.

To do so, click the Save to Pieces button on any code block within the Copilot Chat view.

Saving Active Files to Pieces

If you want to save a really big snippet, try saving your entire file directly to Pieces.

To save your active file:

  1. Right-click within your active file

  2. Hover over the Pieces item

  3. Click Save Active File to Pieces

There are plenty of scenarios in which saving an entire file to your Pieces Cloud is ideal, such as to:

  • Preserve Complex Codebases: Save larger, cohesive files like utility libraries, configuration files, or classes to ensure you capture all interconnected functionality in one place.

  • Reuse in Future Projects: Easily repurpose full files in new projects without reconstructing smaller snippets.

  • Keep Independent Files Versioned: Maintain standalone files, such as scripts or tools, as independent backups or versions outside of source control.

What’s Stored When You Save a Snippet

When you save a snippet to your Pieces Cloud, it’s more than just the code that gets stored.

The Pieces Copilot captures:

  • Type: Categorizes the snippet (e.g., API call, function, class) with it’s code language.

  • Associated Tags: Keywords associated with the snippet for easier searching.

  • Custom Description: Specifies precisely which lines (in numerical form) the snippet is from, as well as the file from which it originated—very useful for mind-mapping.

  • Smart Description: AI-generated descriptions that summarize the snippet’s purpose and function.

  • Suggested Searches: Related searches that help you discover similar snippets.

  • Related Links: References to documentation, code repositories, or other relevant resources.

  • Related People: Associated collaborators or contributors.

Additionally, the Pieces Copilot scans saved snippets for sensitive information, such as API keys, passwords, or authentication tokens, to ensure no confidential data is accidentally stored.

Where Saved Snippets Live

Saved snippets are stored locally on your device, ensuring accessibility even when offline. This also means that any Pieces for Developers extension or plugin—or even the Pieces Desktop App—has constant, up-to-date access to your saved materials.

There are two ways to find your saved snippets—via the Pieces Explorer menu, or with the Pieces: Search Pieces feature.

Read more about how to find your saved snippets here.

Updated on