GitHub Repository
Easily manage your Visual Studio Code (VSCode) snippets directly from Alfred without having to switch between apps. With this workflow, you can seamlessly create, read, update, and delete your snippets without leaving Alfred.
- CRUD Operations: Manage VSCode snippets through simple commands that enable you to create, read, update, and delete snippets effortlessly.
- Clipboard Integration: Quickly register text from your clipboard as a VSCode snippet.
- Customizable Keywords: The default keywords are
snc(Create),snr(Read),snu(Update), andsnd(Delete), but you can easily modify them through the Configuration Builder to suit your preference.
Note: This workflow directly manipulates the JSON files of your VSCode snippets. Any comments in these files will be removed when the workflow modifies them. If you want to preserve comments, consider adding them as JSON elements or refrain from using this workflow.
- Download the workflow:
- Double-click the downloaded workflow file and follow the prompts to install it in Alfred.
- Configure Environment Variables (if needed):
- VSCode Snippet Directory:
- Ensure that the environment variable
vscode_snippets_dirpoints to your VSCode snippets directory. - By default, this path is set to:
~/Library/Application Support/Code/User/snippets/ - If the default path does not work for your setup, find your own VSCode snippets directory and update the environment variable accordingly.
- Ensure that the environment variable
- VSCode Snippet Directory:
Follow these steps to perform basic operations:
-
Input Keywords:
- Open Alfred and type the default keywords (
snc,snr,snu,snd), followed by a space and the language of your snippet. - Example:
snc python(Create a Python snippet)
- Open Alfred and type the default keywords (
-
Select the Language:
- After typing the keyword and a space, choose the programming language for which you want to manage snippets.
- Steps:
- Copy the code you want to register as a snippet to your clipboard.
- Open Alfred, type the keyword
sncfollowed by the language, and choose the language from the suggestions. - Enter the prefix for the snippet.
- The script will register the clipboard content as a new snippet in VSCode.
- Steps:
- Open Alfred, type the keyword
snrfollowed by the language, and choose the language from the suggestions. - Select the snippet prefix from the list to read its content.
- The selected snippet will be copied to your clipboard, and if a text editor is active, it will be pasted automatically.
- Open Alfred, type the keyword
- Steps:
- Copy the updated code to your clipboard.
- Open Alfred, type the keyword
snufollowed by the language, and choose the language from the suggestions. - Select the prefix of the snippet you want to update.
- The existing snippet will be updated with the new clipboard content.
- Steps:
- Open Alfred, type the keyword
sndfollowed by the language, and choose the language from the suggestions. - Select the prefix of the snippet you want to delete.
- The script will remove the selected snippet from your VSCode snippet file.
- Open Alfred, type the keyword
-
Snippet is not being registered:
- Make sure that the
vscode_snippets_direnvironment variable is set correctly. - Verify that you have read/write permissions for the snippet directory.
- Make sure that the
-
Alfred is not responding:
- Restart Alfred to ensure it has loaded the workflow correctly.
- Check that the workflow is enabled in Alfred's settings.
-
Still having issues?:
- Use the workflow's debug mode to see detailed script outputs.
- Based on the debug information, you can take the appropriate action or reach out with a comment if you need further assistance.