Snipsco SenderA VS Code extension that lets you capture and share code snippets to snipsco.com without leaving your editor. Select code, press a shortcut, and get a shareable link — that's the entire workflow. Compatible with VS Code Table of Contents
What Is This?Snipsco Sender is a VS Code extension that connects your editor to snipsco.com — a snippet-sharing service similar to GitHub Gist. Instead of copying code, opening a browser, pasting, and submitting a form, you stay in your editor. The extension handles authentication, collects relevant metadata automatically, and returns a shareable URL the moment the snippet is saved. It is designed for Snipsco account holders — access is controlled by a personal API token from your account. The token is validated when you activate and is stored encrypted on your machine. How It WorksThe flow from selection to shareable link:
The extension stores nothing permanently beyond the encrypted token. The session snippet counter and recent snippets list reset every time VS Code restarts. FeaturesSend Snippet (
|
| Requirement | Detail |
|---|---|
| Editor | VS Code ≥ 1.80.0 or Cursor |
| Account | A snipsco.com account |
| API token | Created from your Snipsco account settings |
| Network | Internet access to reach https://snipsco.com |
Getting Started
1 — Install the Extension
Install from the VS Code Marketplace, or load a .vsix file manually:
Extensions panel → ⋯ → Install from VSIX...
2 — Enter your token
Open the Command Palette (Ctrl+Shift+P / Cmd+Shift+P) and run:
Snipsco: Activate Token
A password-masked input box appears. Enter the API token from your Snipsco account. The extension immediately validates it against the API. On success the status bar shows ✓ Snipsco and the token is stored encrypted.
3 — Send Your First Snippet
- Open any source file.
- Select the code you want to share.
- Press
Ctrl+Alt+S(orCmd+Alt+Son macOS). - Optionally type a note describing the snippet, then press Enter (or leave blank and press Enter).
- Watch the selected lines flash green — your snippet is live.
- Click View Snippet in the notification to open it in the browser.
That's it. The next time you send, your token is already stored and the process goes straight to step 4.
Commands
All commands are available in the Command Palette (Ctrl+Shift+P).
| Command | Description |
|---|---|
| Snipsco: Activate Token | Enter and validate your Snipsco account token. Safe to run again if you rotate your token. |
| Snipsco: Send Snippet | Send the currently selected code. Prompts for optional notes. Shows a notification with a link on success. |
| Snipsco: Send & Copy Link | Send silently without a notes prompt. Copies the URL to your clipboard on success. |
| Snipsco: Recent Snippets | Open a searchable list of snippet URLs sent this session (up to 10). |
| Snipsco: Reset Token | Delete the stored token (with confirmation) and immediately prompt for a new one. |
Keyboard Shortcuts
| Shortcut | Command | Condition |
|---|---|---|
Ctrl+Alt+S / Cmd+Alt+S |
Send Snippet | Text must be selected in a focused editor |
Ctrl+Alt+Shift+S / Cmd+Alt+Shift+S |
Send & Copy Link | Text must be selected in a focused editor |
You can rebind these at any time via File → Preferences → Keyboard Shortcuts (Ctrl+K Ctrl+S), then search for snipsco.
Right-Click Context Menu
When you right-click inside the editor with text selected, a Snipsco group appears at the bottom of the context menu:
| Menu Item | When Visible |
|---|---|
| Snipsco: Send Snippet | When text is selected |
| Snipsco: Send & Copy Link | When text is selected |
| Snipsco: Recent Snippets | Always |
Status Bar
The Snipsco status bar item sits on the right side of the VS Code status bar.
| State | Appearance | Action on Click |
|---|---|---|
| No token stored | ⚠ Snipsco: Inactive – Click to Activate (yellow background) |
Opens the token prompt |
| Token stored, no sends yet | ✓ Snipsco |
Opens the token prompt |
| Token stored, N snippets sent | ✓ Snipsco · N sent |
Opens the token prompt |
Hovering over the item shows a tooltip listing:
- Current activation state
- The
Ctrl+Alt+SandCtrl+Alt+Shift+Sshortcuts - Total snippets sent this session (if > 0)
What Gets Sent to the API
Snippet request
POST https://snipsco.com/snipsco/gists/save
Headers:
Content-Type: application/json
X-Token: (your Snipsco API credential)
Body:
{
"code": "…selected source…",
"notes": "…optional notes…",
"language": "…VS Code language id, e.g. typescript…",
"filename": "…basename only, e.g. utils.ts…",
"lineRange": "…1-indexed range, e.g. 42–67…"
}
The API responds with { "url": "https://snipsco.com/s/..." }.
Validation request
When you enter a token, it is validated before being stored:
POST https://snipsco.com/snipsco/auth/token-validate
Headers:
Content-Type: application/json
X-Token: (credential to validate)
Body: {}
A 2xx response means the token is valid. Any 4xx means it is invalid or expired.
Privacy note: The filename field contains only the file's basename (e.g.
utils.ts), never the full path on your machine.
Configuration
Open VS Code Settings (Ctrl+,) and search for Snipsco to find these options:
| Setting | Type | Default | Description |
|---|---|---|---|
snipsco.apiEndpoint |
string |
https://snipsco.com/snipsco |
API base URL. Snippets are sent to {base}/gists/save; validation uses {base}/auth/token-validate. Change this only for a self-hosted or alternate Snipsco deployment. |
snipsco.alwaysPromptNotes |
boolean |
true |
When true, the standard Send Snippet command prompts you for notes before every send. Set to false to skip the notes prompt (notes will be blank). Has no effect on Send & Copy Link, which never prompts for notes. |
snipsco.keyboardShortcut |
string |
ctrl+alt+s |
Informational only. The actual keybinding is registered in the VS Code keybindings system and can be changed there. |
Security Model
| Concern | How It Is Handled |
|---|---|
| Token storage | Stored via VS Code SecretStorage API — encrypted at rest using the OS credential store (Keychain on macOS, libsecret on Linux, Credential Manager on Windows). Never written to settings.json or any plain-text file. |
| Token transmission | Sent as the X-Token HTTP header on every API request. Never included in the request body. |
| Network | All requests use HTTPS. No plain HTTP. |
| Full file paths | Never sent. Only the filename basename (e.g. utils.ts) is included in the snippet metadata. |
| Logging | The token is never written to the VS Code output channel or browser console. Log statements reference [Snipsco] prefixed messages only about lifecycle events. |
| Invalid token auto-cleanup | If the API returns a 401 or 403, or the error message references an invalid/expired token or key, the stored token is automatically deleted. The next send will prompt for a new one. |
Error Handling
The extension handles these failure cases gracefully:
| Situation | What Happens |
|---|---|
| No code selected | Error notification: "Please select some code before sending a snippet." |
| No active editor | Error notification: "No active editor found." |
| Selection larger than 1 MB | Warning dialog asking whether to proceed or cancel |
| No token stored | The token prompt appears automatically before sending |
| Invalid / expired token | Error shown; stored token deleted; next send will re-prompt |
| Network error (no response) | Error notification: "Network error. Please check your internet connection." |
| Rate limit (HTTP 429) | Error notification with the API-provided message or a default message |
| Server error (HTTP 5xx) | Error notification with the API-provided message or a default message |
| User cancels notes prompt | Send is silently aborted; no API call is made |
Project Structure
snipsco-vscode/
├── src/
│ ├── extension.ts # activate() / deactivate(), command registration
│ ├── sendFlow.ts # runSendFlow() — editor checks, API call, recent list
│ ├── constants.ts # LANGUAGE_MAP, size limits
│ ├── api.ts # All HTTP communication with snipsco.com
│ │ # sendSnippet(), validateToken(), error parsing
│ ├── storage.ts # SecretStorage wrappers: get / store / delete token
│ ├── ui.ts # Status bar rendering, input prompts, notification helpers
│ └── test/
│ ├── runTest.ts # @vscode/test-electron entry point
│ └── suite/
│ ├── index.ts # Mocha test suite loader
│ └── extension.test.ts # Integration tests
├── out/ # Compiled JavaScript output (generated, not committed)
├── package.json # Extension manifest — commands, menus, keybindings, config
├── tsconfig.json # TypeScript compiler options (target: ES2020, module: commonjs)
├── webpack.config.js # Production bundler config (excludes vscode host module)
├── .vscodeignore # Excludes dev files from the .vsix package
└── README.md # This file
Module responsibilities
extension.ts is the orchestrator. It registers all five commands, owns the status bar item and the green sent-decoration, manages the session snippet counter and recent snippets list, and contains the shared doSend(silent) helper that both Send Snippet and Send & Copy call.
api.ts is the network layer. It exports sendSnippet() and validateToken(), both of which pass the account token as the X-Token header. It also exports the SnippetMeta interface and a private parseAxiosError() function that translates HTTP status codes into human-readable messages.
storage.ts is a thin wrapper around context.secrets. It exposes getToken, storeToken, and deleteToken — all async, using the snipsco.token secret key.
ui.ts contains user-facing UI helpers: updateStatusBar(), promptForToken(), promptForNotes(), showInfo(), and showError().
Building from Source
# 1. Clone the repository
git clone https://github.com/wanoo21/snipsco-vscode.git
cd snipsco-vscode
# 2. Install dependencies
npm install
# 3. Compile TypeScript to out/
npm run compile
# 4. Start watch mode (recompiles automatically on file save)
npm run watch
# 5. Press F5 in VS Code to launch an Extension Development Host
# This opens a second VS Code window with the extension loaded.
# 6. Package as a .vsix for distribution
npm run package
# 7. Publish to the Visual Studio Marketplace (optional)
# Create a publisher at https://marketplace.visualstudio.com/manage
# and a Personal Access Token with Marketplace (Manage). Then:
# vsce login <publisher>
# npm run vscode:publish
Tech stack
| Tool | Version | Purpose |
|---|---|---|
| TypeScript | ^5.0 |
Source language |
| VS Code Extension API | ^1.80 |
Host environment |
| fetch (built-in) | Node 18+ | HTTP client for API calls |
| webpack | ^5.76 |
Production bundler |
| ts-loader | ^9.2 |
TypeScript loader for webpack |
| @vscode/test-electron | ^2.3 |
Integration test runner |
| mocha | ^11 |
Test framework |
Running Tests
Tests run inside a real VS Code instance via @vscode/test-electron. They validate command registration, graceful error handling, and the line-range calculation edge case.
# Compile first, then run tests
npm run compile && npm test
Test cases covered:
| Test | What It Checks |
|---|---|
| All five commands are registered | Commands exist in the VS Code registry after activation |
sendSnippet with no editor |
Handles gracefully — no throw |
sendAndCopy with no editor |
Handles gracefully — no throw |
sendSnippet with empty selection |
Handles gracefully — no throw |
recentSnippets with empty history |
Shows info message — no throw |
| Line range edge case | Exclusive-end selection (col 0) is not over-counted |
| Configuration defaults | API endpoint, alwaysPromptNotes, and keyboardShortcut match spec |
License
MIT © Snipsco