Saving Snippets
There are several ways to save code with the Pieces for JetBrains plugin—through the right-click menu, hotkeys, or dragging and dropping code into the Pieces sidebar.
There’s also the fine-tuned saving feature called Save to Pieces As
which lets you edit and adjust the automatically-generated metadata to your liking.
via Right-Click Menu
You can save snippets by accessing the tool menu.
To save a snippet using this method:
Choose your Snippet
Highlight the code you want to save
Open Right-Click Menu
Right-click on the highlighted code and hover on the Pieces
option
Select Action
Select either Save Current Selection to Pieces
or Save File to Pieces
This will trigger a success message in the bottom-right corner of your screen to let you know that the save was successful.
via Keyboard Shortcut
Keyboard shortcuts are another easy way to save useful developer materials.
To save a snippet via keyboard shortcuts:
Choose your Snippet
Highlight the code you want to save
Save your Snippet
Use the command ⌥+⌘+p
(macOS) or ctrl+alt+p
(Windows/Linux) to save the code as a snippet
Saving a snippet via keyboard shortcut will trigger the same success modal in the bottom right-hand corner of your screen to let you know the save was successful.
via Copilot Chat
When you start a conversation about a piece of code in your active file—or have any code block present in your Copilot Chat—you can save it to Pieces using the Save to Pieces
button in the Copilot Chat view.
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.
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 with Pieces Drive.
There are two ways to view your saved snippets—by viewing them in your JetBrains IDE’s sidebar menu, or with the Search Everywhere feature.