Xsnip VS Code Extension
Search, insert, and submit code snippets from Xsnip directly in VS Code.
Features
- Search Snippets: Quickly find code snippets from your Xsnip library.
- Insert at Cursor: Inject snippet code directly into your active editor.
- Save to File: Save a snippet as a new file in your project.
- Submit Snippets: Create new snippets from your current selection or entire file.
Usage
Searching & Using Snippets
- Open the search palette:
- Mac:
Cmd+Shift+X
- Windows/Linux:
Ctrl+Shift+X
- Or run command:
Xsnip: Search Snippets...
- Type your query to filter results.
- Select a snippet and choose an action:
- Insert at Cursor: Pastes code at your current cursor position.
- Save to New File: Creates a new file with the snippet content.
Submitting Snippets
- Select the code you want to save (or select nothing to save the whole file).
- Right-click and choose:
- Xsnip: Submit Selection
- Xsnip: Submit File
- (Alternatively) Use the Command Palette (
Cmd+Shift+P) to run these commands.
Note: You need an API Key to submit snippets.
Configuration
Configure the extension in VS Code Settings (Cmd+, -> Extensions -> Xsnip).
| Setting |
Default |
Description |
xsnip.apiKey |
"" |
Required for submissions. Generate this in your Xsnip Account settings. |
xsnip.baseUrl |
https://xsnip.dev |
URL of the Xsnip server. |
xsnip.insertHeader |
true |
Add a header comment when inserting code. |
xsnip.headerFormat |
// Source: {title} (xsnip:{id}) |
Template for the header comment. Variables: {title}, {id}, {date}. |
Commands
| Command |
Keybinding |
Description |
Xsnip: Search Snippets... |
Cmd+Shift+X |
Open search palette. |
Xsnip: Insert at Cursor |
- |
Insert currently selected snippet. |
Xsnip: Save to New File |
- |
Save currently selected snippet to file. |
Xsnip: Submit Selection |
- |
Upload selected text as a new snippet. |
Xsnip: Submit File |
- |
Upload current file as a new snippet. |
Development
To run this extension locally:
- Clone the repository.
- Install dependencies:
cd vscode
npm install
- Run the extension:
Press
F5 in VS Code to launch the Extension Development Host.
Requirements
| |