SnipHarbor for VS Code
Use your SnipHarbor snippets without leaving the editor. It works with
the hosted instance and any self-hosted server, and with VS Code forks that install from Open VSX.
Features
- Insert a snippet at the cursor:
SnipHarbor: Insert Snippet (Ctrl+Alt+I, Cmd+Alt+I on macOS). Live search over title, description and code; with an empty box it shows pinned and most used snippets. Inserted as plain text, so $HOME stays $HOME.
- Save the selection (
Ctrl+Alt+S), the current file, or several files selected in the Explorer as a snippet, with folder, tags and description.
- Browse pinned, recent, folders and snippets in the SnipHarbor sidebar. Multi-file snippets expand into their files.
- Edit a snippet as a normal tab and save it back with
Ctrl+S. If it changed in the meantime, VS Code offers Compare or Overwrite.
- Run a snippet in the SnipHarbor sandbox; the output opens in the "SnipHarbor" output channel.
- Complete (off by default): turn on
snipharbor.completions.enabled, type snip: and part of a title to get your pinned and most used snippets as suggestions.
- Copy a snippet, or open it in the browser.
Nothing here can delete, trash, publish or pin a snippet.
Signing in
- Set
snipharbor.serverUrl (or you are asked at the first sign-in). https: only, except for localhost.
- SnipHarbor: Sign In opens your browser (OAuth with PKCE, redirect to a local port on
127.0.0.1). The account then shows in VS Code's Accounts menu.
- In Remote SSH, WSL, Codespaces or on a locked-down machine, use SnipHarbor: Sign In with Access Token. Create the token in SnipHarbor under Settings → Data & apps → Access tokens (give it the Run and Create and edit permissions you need).
Tokens are stored in the operating system's keychain (VS Code SecretStorage), never in settings. Signing out of an OAuth connection revokes it on the server; an access token stays valid until you revoke it in Settings.
Settings
| Setting |
Default |
Purpose |
snipharbor.serverUrl |
empty |
Your server's address (machine scope) |
snipharbor.insert.matchIndent |
true |
Indent inserted lines to the column of the cursor |
snipharbor.run.askForStdin |
false |
Ask for standard input before a run |
snipharbor.completions.enabled |
false |
Suggest snippets after the completion prefix |
snipharbor.completions.prefix |
snip: |
The text that starts a suggestion |
snipharbor.tree.pageSize |
50 |
Snippets the sidebar loads at a time |
Not supported yet
Renaming, adding or deleting the files of a snippet, folder management, a web (vscode.dev) build.
Development
npm ci
npm run build # bundles src/extension.ts to dist/extension.js with esbuild
npm run check # tsc
npm test # vitest: the logic that does not need VS Code
npm run test:integration # runs the extension in a real VS Code against a fake server
npm run package # a .vsix
npm run test:integration downloads a VS Code unless VSCODE_EXECUTABLE points at an installed one (it needs a display; use xvfb-run on a headless machine).
Press F5 in VS Code with this folder open to start an Extension Development Host. Publishing is manual:
vsce publish (Marketplace) and ovsx publish (Open VSX, namespace = publisher id).