Searching
You can find your saved code snippets easily with the Pieces for JetBrains Plugin by utilizing a few different search methods.
Finding Saved Snippets
To find and use code snippets inside your JetBrains IDE, you can use the IDE’s built-in Search Everywhere feature.
Whether you’re on macOS, Windows or Linux, all you need to do is double-press the Shift
key twice to open up the Search Everywhere menu.
Once the menu is open, switch to the Pieces
tab, then enter a search query to search your entire Pieces repository for any snippet you’ve saved.
After you’ve located a snippet, you can press Enter
to open it in a new window and view the snippet’s code and saved context.
You can also press shift+shift
and search while remaining in the Search Everywhere menu’s All
tab, but the Pieces
tab is the de-facto home for seeing only saved snippet search results.
The default behavior for the Search Everywhere feature can be changed to whatever keymapping you prefer—learn more about this here.
Viewing and Reusing Saved Snippets
Saved snippets can be viewed alongside their saved metadata by opening up them up directly from the sidebar—either by pressing enter
on a highlighted snippet, or by double-clicking it.
This opens up the snippet in markdown preview mode in a separate window.
From the opened markdown preview, you can then select Copy to Clipboard
in the top-left corner of the snippet’s embedded code box.
This action copies the contents of the saved code to your clipboard, from which you can then paste it wherever it’s needed.
via Pieces Sidebar
You can view snippets by opening up the Pieces sidebar in your JetBrains IDE by clicking the Pieces icon on the left-hand side of your screen.
Once in the sidebar, you can save snippets by highlighting code and dragging it into the sidebar, or perform the inverse operation—drag a snippet out of the sidebar and drop it right where you want it in your code.
You can also right-click a snippet and select Insert at Caret
to insert it at the cursor in your active file.
via Sidebar Preview
If you want to preview saved code without opening it or inserting it into your active file, you can always hover over the snippet with your cursor to trigger the preview modal.
Real Time Snippet Streaming
Each product in the Pieces Suite uses PiecesOS to get information about your snippets' context.
When you update a snippet in the Pieces for Developers Desktop App—such as a name or description, tags or any of the other metadata—those changes are also reflected in your Pieces for JetBrains Plugin without refreshing.
If your snippets are not updating right away, see the troubleshooting guide to details on how to refresh your snippet list.