I Built a VS Code Extension to Upload Code Snippets to PasteDB in One Click ๐Ÿš€
DEV Community

I Built a VS Code Extension to Upload Code Snippets to PasteDB in One Click ๐Ÿš€

How It Works

The extension integrates directly with VS Code's command palette and context menus. You can trigger an upload in two ways:

  • Upload current file - sends the entire active editor content to PasteDB
  • Upload selected code - sends only the highlighted portion of your code

Once triggered, the extension performs automatic language detection based on the file extension or selected code context. It then sends the content to PasteDB's API and returns an instant shareable link.

Installation

  1. Open Visual Studio Code
  2. Go to the Extensions view (Ctrl+Shift+X or Cmd+Shift+X)
  3. Search for "PasteDB"
  4. Click Install

Alternatively, you can install directly from the VS Code Marketplace.

Features

  • Secure API key storage - your API key is stored using VS Code's built-in secret storage
  • Customizable upload settings - configure default expiration, syntax highlighting, and visibility
  • Recent paste history - view and manage your last 50 pastes from within VS Code
  • Automatic language detection - detects programming language from file extension or code context
  • Instant shareable links - copies the paste URL to your clipboard immediately after upload

Challenges I Faced

Building the extension presented several technical challenges:

  1. API key security - storing credentials securely required using VS Code's SecretStorage API rather than plain configuration files
  2. Language detection accuracy - mapping VS Code's language identifiers to PasteDB's supported languages required a comprehensive lookup table
  3. Error handling - network failures and API rate limits needed graceful handling with user-friendly notifications
  4. Cross-platform testing - ensuring consistent behavior across Windows, macOS, and Linux required extensive testing

More Info

View on Marketplace: PasteDB VS Code Extension

For further actions, you may consider blocking this person and/or reporting abuse

Top comments (0)

Comments

No comments yet. Start the discussion.