Skip to main content

Transforming Snippets

Snippets are sometimes very close to the format you need, or they would be better utilized as boilerplate for different applications. With transformations, you can save even more time while coding. Transformations can convert languages, improve code readability and performance, and create boilerplate templates, all in a single click.

Getting Started with Snippet Transformations

In order to access the snippet transformations, first you need to save your first code snippet. Once you have code in the Pieces Desktop App:

  1. Use ⌘/CTRL + E or click Edit this snippet, which will open the Edit Mode and change the icons in the Quick Action Menu.

  2. Each of the icons here represents a different transformation style:

    • Modify Snippet for Boilerplate Usage
      • Transform a code snippet into a boilerplate template in seconds, complete with any notes as code comments. This makes it extremely easy to make your code even more reusable.
    • Modify Snippet for Improved Performance
      • Re-write a code snippet in its current language to be more performant
    • Modify Snippet to Improve Readability & Understanding
      • Learning a new programming language? With just two clicks, you can edit your code snippets to be more human-readable. This makes it much easier to understand how a code snippet works, and is useful for developers of all experience levels.
    • Transform or Translate a Snippet with a Description
      • Can translate the snippet from one language into another.
      • (Optional) Add a description that can help guide the transformation of the snippet.
  3. Once you perform any of the transformations, you will have a few options on how to complete the transformations process. You choose any of the following:

    • Save and Exit
    • Save as Duplicate (This saves the original and the new transformed version)
    • Discard and Exit
    • Undo Changes
  4. Once you select a specific transformation for a snippet, Pieces will mark the transform icon with a green checkmark if you have already performed that specific transformation.

Our Transformations are currently in Beta - please share any feedback so that we can continue to make them more useful!