README file from
GithubSnippets Manager - Text Expansion Plugin for Obsidian
Overview
The Snippets Manager Plugin for Obsidian allows you to manage and quickly insert text snippets stored in a markdown file (or folder of markdown files, including subfolders). This plugin enhances your workflow by enabling fuzzy search for snippets, allowing you to copy them to your clipboard or directly paste them at the cursor position in your active note. Now, with Alfred integration, it's even more powerful.
New Features
Alfred Support
Snippets can now be saved in Alfred JSON format for integration with Alfred. If enabled, your snippets will be automatically saved in a JSON format compatible with Alfred workflows.
How to Use Alfred Support:
- In the plugin settings, toggle Enable Alfred Support.
- Snippets will be saved as alfred-snippets.json inside the plugin folder.
- Install the alfred workflow by downloading here
- You need to add the alfred-snippets.json file path to the alfredworkflow configuration. [In the snippets manager plugin settings panel, the full path to the generated Alfred JSON file is displayed, and you can copy it by double clicking and copy it for easy access.]
Templater Support
You can now use Templater syntax in your snippets! If you have the Templater plugin installed, any snippet containing <% will be processed by Templater before insertion.
Example:
### Today's Date
Today is <% tp.date.now("YYYY-MM-DD") %>
Usecases
Do i need this plugin if i already you Text Expander kind of apps?
Yes, you need it. In most of the cases, those apps will be available only for desktops. But this plugin will work on your mobile too.
Mobile Use:
I use Snippet Manager to quickly copy things like addresses, map locations, URLs, and quotes. With the help of the "Website shortcut" Android app and the Obsidian Advanced URI plugin, I’ve set up a shortcut directly to the snippet search modal. Now, with just one click, I can copy whatever I need to my clipboard and paste it anywhere on my phone.
Example Advanced URI link for Obsidian. You can create the link to the URL. [Replace your vault name accordingly]
obsidian://advanced-uri?vault=<your-vaultname>&commandid=snippets-manager%3Aopen-snippet-search
Features
- Snippet Management: Store snippets in a markdown file with headings as keys (whether personal details like email signature, passport number, code snippets or anything).
- Multiple Locations & Tags Support: You can define multiple comma-separated file/folder paths to aggregate snippets. You can also specify comma-separated
#tagsto dynamically pull snippets from any note in your vault containing those tags. - Path Prefixing: By default, snippets from subdirectories or tags include their directory path (or vault path) in their visual name. A toggle is available in settings to disable this and only show the base file name.
- Code Snippets: The plugin supports code snippets stored in markdown code blocks. When retrieving a code snippet, the plugin automatically strips the backticks, providing you with just the clean code.
- Fuzzy Search: Quickly search through snippets using a fuzzy search interface.
- Clipboard Copying: Copy selected snippets to your clipboard.
- Direct Insertion: Paste snippets directly at the cursor position in the active markdown note.
- Configurable Snippet Location: Choose a markdown file or folder to store your snippets.
- Mobile Support: The plugin is fully compatible with Obsidian's mobile app. You can easily create a shortcut to the Snippet Search using the Advanced URI plugin, making it even more convenient to search and copy snippets on the go.
- Alfred Support: Generate an Alfred-compatible JSON file for use in Alfred workflows. This file is saved inside the Snippet Manager plugin folder, and the path can be easily copied from the settings.
- Templater Support: Support for Templater syntax. Snippets with
<%will be processed by Templater before insertion.
Links
✨ Check out latest updates 🪲 Report bugs and suggest features ❓ Ask questions 👍 Give thumbs up to issues important to you
Installation
- Obsidian Community Plugins:
-
This plugin will be available in the Obsidian community plugins list. If so, you can install it directly from Obsidian:
-
Go to
Settings>Community Plugins>Browse. -
Search for
Snippets Manager. -
Click
Installand thenEnable. -
Or just install directly into Obsidian.
-
Usage
Setting Up Snippets
- Multiple Paths and Tags Setup:
You can store snippets in single markdown files (e.g., Snippets.md), across multiple folders (e.g., Programming/), or dynamically pull them from any markdown file tagged with specific tags (e.g., #snippet).
In the plugin settings, you can provide a comma-separated list of locations and another for tags.
- Markdown Snippet Structure:
- Each snippet should be stored under a heading (### Heading), with the content under the heading representing the snippet.
- Example in a single file:
### Greeting
Hello, how are you doing today?
### Signature
Best regards,
[Your Name]
### Hello World
```js
helloworld() {
console.log("Hello World!!!");
}
```
-
Example with multiple files:
- Snippets/Email.md (with headings for email templates)
- Snippets/Code.md (with headings for code snippets)
- Configure Snippet Settings:
- In Obsidian, go to
Settings>Snippets Manager. - Set the
Snippets locationsto your snippet files or folders separated by commas (e.g.,Snippets.md, Support/). - Alternatively or additionally, set
Snippets tagsto dynamically resolve snippets (e.g.,#snippet, #templates). - Adjust
Show full folder path as prefixif you want to hide or show long directory paths in your snippet names.
- In Obsidian, go to
Using Snippets Manager
-
Search and Insert Snippets:
- Use the command palette (CMD/CTRL + P) and search for
Search Snippets. - A fuzzy search modal will appear, allowing you to search for your snippets by their headings.
- Press
Enterto copy the snippet to your clipboard. - Press
CMD/CTRL + Enterto paste the snippet directly at the cursor position in the active note.
- Use the command palette (CMD/CTRL + P) and search for
-
Keyboard Shortcuts:
Enter: Copy the selected snippet to the clipboard.CMD/CTRL + Enter: Copy the selected snippet to the clipboard and paste it at the cursor position in the active note.
Development
Requirements
- Node.js and npm
- TypeScript
Building the Plugin
-
Clone the repository:
git clone https://github.com/your-repo/snippet-manager cd snippet-manager -
Install dependencies:
npm install -
Build the plugin:
npm run build -
Develop with live reload:
npm run dev
Contributing
Contributions are welcome! If you have any bug reports, feature requests, or code improvements, feel free to open an issue or submit a pull request.
License
This plugin is open-source software licensed under the MIT License.