Back to Dashboard
Documentation/Features/Code Snippets

Code Snippets

Save and organize reusable code

Code Snippets

The Snippets feature lets you save, organize, and reuse code snippets across your projects. Build a personal library of commonly used patterns, utilities, and solutions.

Overview

Access Snippets from the ReformCode page by selecting the Snippets tab. Features include:

  • Save snippets: Store code with metadata
  • Organize: Tags and categories
  • Search: Find snippets quickly
  • Copy: One-click copy to clipboard
  • Edit: Update snippets anytime
  • Sync: Available across devices

Getting Started

Saving Your First Snippet

  1. Navigate to ReformCode
  2. Click the Snippets tab
  3. Click New Snippet
  4. Enter snippet details:
    • Title: Descriptive name
    • Language: Programming language
    • Tags: Comma-separated keywords
    • Code: Your snippet content
  5. Click Save

From the Editor

  1. Write or paste code in the Editor tab
  2. Select the code you want to save
  3. Right-click and select Save to Snippets
  4. Or use the Save Snippet button
  5. Add title and tags
  6. Save

Organizing Snippets

Using Tags

Tags help categorize and find snippets:

Tags: react, hooks, useEffect, cleanup
Tags: utility, string, formatting
Tags: api, fetch, error-handling

Best practices:

  • Use consistent naming
  • Include language tags
  • Add context tags (frontend, backend, etc.)
  • Include pattern names (singleton, factory, etc.)

Categories

Snippets are automatically grouped by language:

  • JavaScript/TypeScript
  • Python
  • Go
  • CSS
  • SQL
  • Other

Favorites

Star frequently used snippets for quick access:

  1. Hover over a snippet
  2. Click the star icon
  3. Find favorites at the top

Managing Snippets

Editing

  1. Click a snippet to expand
  2. Click Edit button
  3. Modify title, tags, or code
  4. Save changes

Deleting

  1. Click the snippet
  2. Click Delete button
  3. Confirm deletion

Duplicating

  1. Click a snippet
  2. Click Duplicate
  3. Modify the copy as needed
  4. Save as new snippet

Searching Snippets

Use the search bar to find snippets by:

  • Title
  • Tags
  • Code content
  • Language

Filters

Filter snippets by:

  • Language: Show only Python, JavaScript, etc.
  • Tags: Filter by specific tags
  • Date: Recent or oldest first
  • Favorites: Show starred only

Keyboard Shortcut

Press Cmd/Ctrl + K to quick search from anywhere in ReformCode.

Using Snippets

Copy to Clipboard

  1. Find your snippet
  2. Click Copy button
  3. Paste in your project

Insert in Editor

  1. In the Editor tab
  2. Open Snippets sidebar
  3. Click a snippet
  4. Code inserts at cursor

Export Snippets

  1. Select snippets to export
  2. Click Export
  3. Choose format:
    • JSON (for backup/import)
    • Markdown (for documentation)
    • Plain text (for sharing)

Import Snippets

  1. Click Import
  2. Select JSON file
  3. Review snippets
  4. Confirm import

Snippet Templates

React Component

import React from 'react';

interface ${1:ComponentName}Props {
  ${2:// props}
}

export function ${1:ComponentName}({ ${3} }: ${1:ComponentName}Props) {
  return (
    <div>
      ${4:// content}
    </div>
  );
}

API Fetch

async function fetchData<T>(url: string): Promise<T> {
  const response = await fetch(url);
  if (!response.ok) {
    throw new Error(`HTTP error! status: ${response.status}`);
  }
  return response.json();
}

Error Handler

function handleError(error: unknown): string {
  if (error instanceof Error) {
    return error.message;
  }
  return String(error);
}

Best Practices

Naming Conventions

Use clear, descriptive titles:

  • "React useEffect Cleanup Pattern"
  • "Python API Error Handler"
  • "SQL Join with Aggregate"

Documentation

Add comments to explain usage:

/**
 * Debounce function - delays execution until pause in calls
 * @param fn - Function to debounce
 * @param delay - Milliseconds to wait
 * @returns Debounced function
 */
function debounce(fn, delay) {
  // ...
}

Keep Snippets Focused

  • One purpose per snippet
  • Include only necessary code
  • Remove project-specific details
  • Make it reusable

Sync Across Devices

Snippets are saved to your account and available:

  • On any browser when logged in
  • Across computers
  • After browser cache clears

Privacy & Storage

  • Snippets are private by default
  • Stored encrypted in our database
  • Not shared with other users
  • Deleted when you delete them

Troubleshooting

Snippets not saving

  • Check your internet connection
  • Ensure you're logged in
  • Try refreshing the page

Search not finding snippets

  • Check spelling
  • Try different keywords
  • Clear filters

Import failed

  • Verify JSON format
  • Check file size limit (1MB)
  • Try smaller batches

Next Steps: