A 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 ≥ 1.80 and Cursor (Cursor is built on VS Code).
- What Is This?
- How It Works
- Features
- Requirements
- Getting Started
- Commands
- Keyboard Shortcuts
- Right-Click Context Menu
- Status Bar
- What Gets Sent to the API
- Configuration
- Security Model
- Error Handling
- Project Structure
- Building from Source
- Running Tests
- License
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.
The flow from selection to shareable link:
1. You select code in any file
↓
2. Trigger the command (shortcut, right-click, or palette)
↓
3. Extension checks for a stored token
→ If missing: prompts you to enter one and validates it against the API
↓
4. Extension auto-collects metadata:
filename (basename only), language, line range
↓
5. Optionally prompts for notes (standard send mode only)
↓
6. POST request to the Snipsco API
Headers: X-Token: (your Snipsco API credential)
Body: { code, notes, language, filename, lineRange }
↓
7. On success:
- Selected lines flash green in the editor for 3 seconds
- Status bar count increments (e.g. "✓ Snipsco · 3 sent")
- Snippet is added to the session Recent Snippets list
- Standard mode: notification with "View Snippet" button
- Send & Copy mode: URL silently written to clipboard
The extension stores nothing permanently beyond the encrypted token. The session snippet counter and recent snippets list reset every time VS Code restarts.
Select any amount of code and send it to Snipsco with one keystroke. You will be prompted for optional notes before sending. On success a notification appears with a View Snippet button that opens the URL in your browser.
A faster, silent variant. It skips the notes prompt entirely, sends the snippet, and copies the URL directly to your clipboard — no notification popup. The green line flash and status bar count update are the only feedback. Paste the link wherever you need it.
Every snippet automatically includes:
- Language — detected from the file type (e.g.
typescript,python,go) - Filename — the basename of the current file (e.g.
utils.ts), never the full path - Line range — the exact lines selected (e.g.
42–67), 1-indexed
You never have to fill these in manually.
The moment a snippet is successfully sent, the selected lines are highlighted with a soft green background directly in the editor. The highlight fades after 3 seconds. This gives you an immediate visual confirmation without taking your eyes off the code.
The status bar item tracks how many snippets you have sent in the current session. After the first send it shows ✓ Snipsco · 1 sent, updating with each subsequent send. Hovering over it shows the full count and a reminder of available shortcuts. The counter resets when VS Code restarts.
Run Snipsco: Recent Snippets from the Command Palette or right-click menu to open a searchable list of every snippet URL sent this session (up to the last 10). Each entry shows the filename and line range, the URL, and the language. Selecting an entry opens it in your browser.
Your Snipsco account token is stored in VS Code's built-in SecretStorage API, which encrypts the value at rest using the operating system's native credential store. The token is never written to settings.json or any plain-text file.
| 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 |
Install from the VS Code Marketplace, or load a .vsix file manually:
Extensions panel → ⋯ → Install from VSIX...
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.
- 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.
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. |
| 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.
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 |
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)
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/..." }.
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.
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. |
| 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. |
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 |
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
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().
# 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| 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 |
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 testTest 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 |
MIT © Snipsco