code-snippet-manager
approvedby jingmengzhiyue
Collect, organize, format, search, and explain code snippets in Markdown. - This plugin has not been manually reviewed by Obsidian staff.
code-snippet-manager
code-snippet-manager is a Markdown-first code snippet manager for Obsidian. It helps you collect, organize, search, copy, and insert reusable code snippets without moving your source data into a private database.
Markdown files remain the source of truth. A single collection file contains snippets for one language, and each snippet uses a level-2 heading, optional tags, and one fenced code block. The heading is only an internal Markdown boundary; inserting a snippet inserts code only, not the heading. Snippets may omit a visible title.
Features
- Create snippets from the current editor selection.
- Create snippets from clipboard content.
- Create snippets directly from the dashboard.
- Store multiple snippets in one Markdown collection file.
- Use Obsidian block IDs as stable jump targets.
- Index snippets in memory from Markdown files.
- Search snippets by keyword, language, and tag.
- Preview matching code in the dashboard using the current Obsidian theme.
- Open a snippet at its original Markdown location.
- Copy only the snippet code.
- Insert snippet code into the active note.
Status
This is an early stable release intended for manual installation, testing, and community review.
Implemented in this release:
- Markdown-backed snippet collections.
- Snippet creation from selection and clipboard.
- Snippet parsing, indexing, and search.
- Dashboard creation flow.
- Search view grouped by Markdown file.
- Recursive snippet root directory selection.
- Common-first, Prism-compatible language choices.
- Required language-scoped snippet tags and theme-aware dashboard previews.
Not included in this release:
- Vector search or embeddings.
- Cloud sync.
- Online code execution.
- SQLite or other private snippet databases.
- Mobile support.
- Formatter actions.
- AI explanations.
Installation for Manual Development
-
Install dependencies:
npm install -
Build the plugin:
npm run build -
Create the plugin folder in your vault:
<Vault>/.obsidian/plugins/code-snippet-manager/ -
Copy these files into that folder:
manifest.json main.js styles.css -
Reload Obsidian.
-
Enable code-snippet-manager from Settings -> Community plugins.
Development
Use the watch build while developing:
npm run dev
Use the production build before packaging a release:
npm run build
Run lint checks with:
npm run lint
Markdown Collection Format
code-snippet-manager indexes Markdown files whose frontmatter contains:
type: code-snippet-collection
A collection file can contain multiple snippets, but it should contain only one language. Each level-2 heading is treated as a snippet section when that section contains a fenced code block.
---
type: code-snippet-collection
title: Oracle 11g Common SQL
default_language: sql
tags:
- code/sql
- collection/oracle11g
created: 2026-07-07
updated: 2026-07-07
---
# Oracle 11g Common SQL
## Query by time range ^snip-sql-time-range
#code/sql/oracle11g #code/sql/time-range
```sql
-- Query records by start time and end time with second-level precision.
SELECT *
FROM FCE.F4_DATA
WHERE COLLECT_TIME >= TO_DATE(:startTime, 'YYYY-MM-DD HH24:MI:SS')
AND COLLECT_TIME <= TO_DATE(:endTime, 'YYYY-MM-DD HH24:MI:SS');
```
Snippet Model
code-snippet-manager uses the following Markdown model:
One Markdown file = one snippet collection
One default_language value = the language for that file
One level-2 heading = one snippet
One fenced code block inside that section = the snippet code
One compact Obsidian tag line = snippet-level searchable code tags
One optional first-line language comment = snippet description (supported languages only)
One Obsidian block ID = stable jump target
Only the lightweight format shown above is indexed. snippet-meta comments are treated as ordinary Markdown comments and are not read.
Creating Snippets
To create a snippet from selected code:
- Select code in the active Markdown editor.
- Run Create snippet from selection from the command palette.
- Enter the optional snippet title, choose a language from the single-select dropdown, add tag bodies, choose a target collection file or enter a new collection file, then enter the optional description and code.
- Confirm the dialog.
code-snippet-manager will create the target collection file if it does not already exist, append the new snippet section, and rebuild the index for that file.
Generated snippets include:
- A level-2 Markdown boundary. If the title is blank, it is written as
## ^snippet-idwithout a visible title. - A stable block ID.
- A compact Obsidian tag line such as
#code/sql/oracle11g #code/sql/time-range. - A fenced code block.
- Optional description text as the first comment line when the selected language has reliable comment syntax.
The title field is optional. When it is blank, code-snippet-manager keeps only the block ID in the Markdown boundary and does not create a fake title such as Untitled snippet. The heading is not inserted into notes.
The description field is optional. For languages with reliable comment syntax, code-snippet-manager saves it as the first comment, for example -- for SQL, # for shell-like languages, /* ... */ for CSS, and <!-- ... --> for HTML or Markdown. Formats without reliable comment syntax, such as JSON, CSV, and plain text, ignore the description so the saved snippet remains valid code.
Code tags are always saved under the selected language. Enter only comma-separated tag bodies such as oracle11g and time-range; code-snippet-manager saves them as #code/sql/oracle11g and #code/sql/time-range when SQL is selected. If the tag field is empty, the language root tag such as #code/sql is saved instead.
Version 1.0.4 does not add compatibility aliases or migrate legacy #code/<tag> tags. Update old snippet tags manually if you want the stored Markdown to follow the new language-scoped contract. Dashboard tag filtering continues to accept partial tag-body text such as oracle or time-range for canonical tag paths.
Searching Snippets
Run Open snippet search to open the code-snippet-manager search view.
The dashboard includes:
- A create button for adding snippets directly.
- A keyword search input.
- A language dropdown filter.
- A comma-separated tag filter. You can type partial tag text such as
oraclewithout#. - Markdown files grouped by path.
- Each file's language and snippet count.
- Expandable snippet cards.
- An optional code preview of up to eight lines that follows the active Obsidian theme.
Each result card shows:
- Heading.
- Tags.
- Description from the first supported code comment line.
- Actions for Open, Copy, and Insert.
The Insert action inserts only the snippet code from inside the fenced code block. It does not insert the snippet heading, title, tags, or description metadata.
Privacy and Security Disclosures
code-snippet-manager is local-first. Markdown files in your vault remain the source of truth, and the plugin does not use a remote database, cloud sync, analytics, telemetry, ads, automatic update mechanism, or network API.
File access is limited to the Obsidian vault:
- The plugin reads Markdown files in the configured snippet root directory to build an in-memory search index. It does not scan the entire vault for snippets.
- The plugin creates or updates Markdown snippet collection files inside the vault when you explicitly create snippets.
- The plugin does not access files outside the vault.
- The plugin does not execute, compile, or run snippet code.
Clipboard access is explicit:
- The plugin reads the system clipboard only when you run Create snippet from clipboard.
- The plugin writes to the system clipboard only when you use a Copy action or Copy current snippet code.
Settings
code-snippet-manager includes settings for:
- Snippet root directory: a single-select dropdown that recursively lists vault folders.
CodeSnippetsis always available, and the current saved path remains selectable even if that folder no longer exists. Only Markdown files inside the selected folder are indexed. - Default language: a single-select dropdown. Except for a retained existing custom or legacy value, the 18 most common choices appear first: Plain text, JavaScript, TypeScript, Python, Java, C, C++, C#, Go, Rust, SQL, Bash, PowerShell, HTML, CSS, JSON, YAML, and Markdown. More mainstream languages supported by Obsidian's Prism-based code highlighting follow alphabetically.
- Enable preview: shows or hides compact Dashboard previews. Preview colors automatically follow the current Obsidian theme.
Future Plan
- Restore formatter actions after the save and preview flow is stable.
- Add optional AI explanations with explicit opt-in and clear privacy disclosure.
Release
The current release version is:
1.0.4
Release assets should include:
manifest.json
main.js
styles.css
Release tags are built by GitHub Actions. The workflow uploads the release assets and creates artifact attestations for provenance verification.
GitHub release tags must use the exact version number:
1.0.4
Do not use a leading v such as v1.0.4.
Release History
1.0.4
- Recursively list vault folders in the snippet root directory dropdown while retaining the current saved path.
- Expand the single-select language catalog with 18 common choices first and more mainstream Prism-compatible languages alphabetically.
- Always save new snippet tags as
#code/<language>/<tag>, or#code/<language>when no tag body is entered. - Keep Dashboard language and tag filtering aligned with the required language-scoped tag structure without legacy-tag compatibility.
- Add optional eight-line Dashboard code previews that follow the active Obsidian theme.
- Refine settings, capture, and Dashboard styling and interactions to match native Obsidian patterns.
1.0.3
- Add an option to include or omit the language prefix in new snippet tags.
- Make new collection file input mutually exclusive with the target collection dropdown.
- Keep new collection file blank by default.
- Improve optional description handling across language comment syntaxes.
- Limit indexing and target file suggestions to the configured snippet root directory.
- Add a GitHub Actions release workflow with artifact attestations.
- Remove CSS
!importantfrom dropdown styling.
1.0.2
- Fix repeated dropdown arrow rendering in snippet creation, dashboard filters, and settings.
1.0.1
- Keep untitled snippets untitled in Markdown by writing
## ^snippet-id. - Use dropdown controls for snippet language selection.
- Use a theme-consistent dropdown for the snippet root directory setting.
- Refine dashboard styling to better match Obsidian themes.
1.0.0
- Simplify the Markdown snippet format for stable community use.
- Remove formatter and AI actions from the current release.
- Add dashboard-based snippet creation.
- Group dashboard results by Markdown collection file.
- Use compact Obsidian code tags such as
#code/sql/oracle11g. - Support fuzzy tag filtering without typing
#.
0.1.2
- Build release assets without minification so the bundled JavaScript remains readable for Obsidian community review.
0.1.1
- Add explicit privacy, network, AI provider, and vault file-access disclosures.
- Replace background Markdown writes with
Vault.process. - Set
authorUrlto the author's GitHub profile.
0.1.0
- Rename the plugin to
code-snippet-manager. - Update package, manifest, README, styles, and source identifiers to match the new name.
0.0.1
- Initial MVP release.
License
Licensed under the BSD Zero Clause License (0BSD).
For plugin developers
Search results and similarity scores are powered by semantic analysis of your plugin's README. If your plugin isn't appearing for searches you'd expect, try updating your README to clearly describe your plugin's purpose, features, and use cases.