Saving
The Pieces for Visual Studio Extension lets you save code snippets in multiple ways, keeping your most useful code easily accessible.
Saving Snippets
Save code with the Pieces for Visual Studio Extension by using the right-click menu or hotkeys.
Use this feature to save all kinds of useful code materials, such as:
-
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
Highlight Selection
Select the portion of code you’d like to save
Right-Click
Right-click on the highlighted section and hover over the Pieces
option
Select Save to Pieces
Choose the Save to Pieces
option to save the selection to Pieces Drive
via Keyboard Shortcuts
If you prefer not to use your cursor, you can quickly save your selected code with keyboard shortcuts.
To do this:
Highlight Selection
Select the portion of code you’d like to save
Use Shortcut
Use the alt+m, s
shortcut to save the selection to Pieces Drive
via Copilot Chat
You can save any code block from your Copilot Chat by clicking Pieces > Save to Pieces
. This includes code generated by Pieces Copilot, code blocks you've added as context but haven't saved as individual snippets, and any other code.
Just click the Save to Pieces
button on any code block in 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:
Right-Click
Right-click within your active file
Locate the Pieces Section
Hover over the Pieces
item in the right-click options
Save Active File to Pieces
Click Save Active File to Pieces
There are plenty of scenarios in which saving an entire file to your Pieces Drive is ideal, such as to:
-
Preserve Complex Codebases: Save large, complete files like utility libraries, configuration files, or classes to keep all related functionality together.
-
Reuse in Future Projects: Use full files in new projects without having to rebuild smaller parts.
-
Keep Independent Files Versioned: Store standalone files, like scripts or tools, as separate backups or versions outside of source control.
What’s Stored When You Save a Snippet
When you save a snippet to your Pieces Drive, 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 checks saved snippets for sensitive information, like API keys, passwords, or authentication tokens, to make sure no confidential data is stored by mistake.
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.
You can find your saved snippets in the Pieces Drive
menu.