Locate Materials in Pieces Drive
To locate your snippets, open a file in VS Code and use one of two methods—searching with the Pieces Drive menu, or with keyboard shortcuts.
How to Search for Saved Materials
You can search for snippets of code and other materials saved to your Pieces Drive right from within the editor. You can also apply search filters to help narrow down results.
via Pieces Drive
If you want to access your saved snippets directly within the VS Code editor, you can:
<Image src="https://storage.googleapis.com/hashnode_product_documentation_assets/vs_code_extension_assets/using_snippets/search_and_reuse/opening_a_snippet.gif" alt="" align="center" fullwidth="true" />
via Search Feature
You can also use Pieces: Search Pieces to find specific snippets—this is where you’ll enter a specific query, which is useful when you know exactly what you want:
<Image src="https://storage.googleapis.com/hashnode_product_documentation_assets/vs_code_extension_assets/using_snippets/search_and_reuse/search_snippets.gif" alt="" align="center" fullwidth="true" />
Adding Filters to your Search
Saved Snippets being viewed in the Pieces Drive can be filtered down by snippet tags, coding languages, and snippet titles.
To filter through your snippets:
<Image src="https://storage.googleapis.com/hashnode_product_documentation_assets/vs_code_extension_assets/using_snippets/search_and_reuse/filtering_snippets.gif" alt="" align="center" fullwidth="true" />
When you’ve finished entering your filters, the Pieces Explorer will only display the snippets that match your filters. You can clear this by clicking the siphon icon with an x over it.
Viewing and Reusing Saved Snippets
Saved snippets can be viewed alongside their saved metadata by opening up them up directly from the Pieces Drive or by clicking on them once they’ve been found using the Pieces: Search Pieces function from the dropdown list. You can also right click on the editor and select Search Pieces in the right-click options.
After opening a snippet, the snippet in markdown preview mode opens up in a separate window.
From this view, you can then highlight the code and right-click to copy the code to your clipboard, or use the ⌘+c (macOS) or ctrl+c (Windows/Linux) shortcut.
via Right-Click Menu
The Pieces for VS Code Extension provides a host of actions that appear once you right-click a snippet from within the Pieces Drive menu.
There are a number of available material management and Pieces Copilot-related actions available on this menu, which you can read more about here—or view an expanded table of them below.
via Pieces Sidebar
You can view snippets by opening up the Pieces Drive sidebar in your VS Code by clicking the Pieces Drive icon on the left-hand side of your screen.
Once in the sidebar, you can insert a snippet and place it exactly where you want it in your code by clicking Insert at Cursor.
You can also right-click a snippet and select Copy to copy it to the clipboard, allowing you to paste it anywhere you need.
Previewing Saved Snippets
While using the Pieces: Search Pieces function, you can click on one of the snippets on the dropdown list to view it’s code before selecting the snippet.
Add to Copilot Context |
Ask Copilot |
Copy |
|---|---|---|
Insert at Cursor |
Shareable Links |
Annotations |
Links |
Tags |
Reclassify |
Edit |
Rename |
Delete |
Real-Time Snippet Streaming
Every product within the Pieces Suite utilizes PiecesOS to gather information regarding the context of your snippets.
When you modify a snippet in the Pieces Desktop App—like changing its name or description, tags, or any other metadata—those updates are automatically shown in your Pieces Drive without the need for refreshing.