Snippets plugin for the Ace and CodeMirror editors in Acode. It provides code autocompletion for the languages listed below.
NOTE: This plugin is not fully supported in Acode version lower than v1.6.0 (212). Please update your Acode App to latest version for using this plugin.
A snippet turns a short trigger into a reusable code template. For example, in
a JavaScript file, type fun to use the function snippet.
The workflows below apply to CodeMirror. Ace continues using its native snippet completion and expansion behavior.
- Start typing a snippet trigger.
- Select the suggestion marked with the plugin logo and confirm it. You can also type the complete trigger and press Tab to expand it directly.
Turning off Autocomplete suggestions hides plugin snippets from completion menus, but it does not disable snippet expansion. Acode's built-in, word, or language-server suggestions may still open while you type.
- Type the complete snippet trigger.
- If a completion menu is visible, press Esc once to close it.
- Press Tab to expand the snippet. If no menu is visible, press Tab directly.
When a completion menu is visible, Esc dismisses it. Once a snippet session is active, Esc ends that session.
After expansion, the first editable field is selected. Press Tab to move to the next field and Shift+Tab to move to the previous one. Repeated fields and transformed values update as you edit.
If a snippet does not expand, check that:
- The complete trigger is typed exactly, including any punctuation or case.
- The file has the correct language mode.
- The expected snippets directory is shown below Set snippets directory.
- A language mapping is configured when the mode and snippet filename differ.
- Any open completion menu has been dismissed with Esc before pressing Tab.
On a fresh CodeMirror installation, the plugin creates
/public/.acode-snippets in Terminal Home and copies every bundled snippet
there. This makes the active snippets editable without choosing a directory
first. Enable hidden files in the file browser, or use ls -a in the terminal,
to see the directory.
Existing installations are not migrated, and existing files are never overwritten. Ace installations continue to use the bundled snippets by default. Resetting the snippets directory also returns to the bundled snippets. The plugin settings show the active directory below Set snippets directory.
Uninstalling the plugin clears its remembered directory so a later reinstall
starts fresh. The editable .acode-snippets directory and its contents are
preserved.
- Open command palette
- Type
set snippets path - Create a new directory or select a directory with snippets in it.
- Navigate to the snippet directory, open and edit any snippets file
The selected directory is applied immediately. Existing Ace-format .snippets files remain compatible.
- Open command palette
- Type
reset snippets path
The bundled snippets are restored immediately.
CodeMirror users can open Language mappings in the plugin settings to map
an Acode language mode to an existing snippet file. For example, zig → rust
loads rust.snippets whenever a Zig file is active. The .snippets suffix is
optional when creating a mapping.
Mappings are only needed when the Acode mode and snippet filename differ, or
when one language should reuse another language's snippets. A zig.snippets
file already works with the zig mode without a mapping. Custom mappings take
priority over built-in aliases, and deleting a mapping restores the built-in
behavior.
Each snippets directory has its own mappings. Switching directories activates the mappings previously saved for that directory. Ace continues using its native mode and snippet resolution unchanged.
Ace-format triggers, scopes, guards, tab stops, mirrors, choices, variables, conditionals, and TextMate transforms work in CodeMirror. Follow the Using snippets guide above for autocomplete, direct expansion, and field navigation.
Snippet suggestions use the plugin logo in CodeMirror's completion menu, making them easy to distinguish from other suggestions. The CodeMirror-only Autocomplete suggestions setting controls whether snippets appear in that menu; it does not disable trigger-plus-Tab expansion, placeholder choices, or field navigation.
The plugin detects JavaScript and CSS regions embedded in HTML and PHP. Native Ace builds continue to use Ace's own snippet engine and completion behavior.
Files ending in .snippets are detected as the Snippets language in
CodeMirror. Comments, directives, regex guards, tab-indented bodies,
placeholders, choices, variables, and transforms receive syntax highlighting.
The plugin logo is also used as the file icon in tabs and the file browser.
Ace already includes its own native snippets language mode, which remains unchanged.
- Abc
- ActionScript
- Blade
- C/C++
- Clojure
- Coffee
- CsoundSynthesizer
- CsoundOrchestra
- CSS
- Dart
- Diff
- Django
- Drools
- Edifacts
- Erlang
- Fsl
- Gobstones
- Golang
- Graphqlschema
- Haml
- Haskell
- HTML
- Java
- JavaScript
- Jsp
- Jsx
- Kotlin
- Liquid
- Lsl
- Lua
- Makefile
- Markdown
- Maze
- Perl
- Php
- Python
- R
- Razor
- Robot
- Rst
- Ruby
- Rust
- Sh
- Snippets
- SQL
- SQLServer
- Swift
- TCL
- Textile
- Tsx
- Twig
- Typescript
- Velocity
- Wallok
Run npm run dev (or the backward-compatible npm run start-dev) to watch the bundle and serve the completed archive over local HTTP. The command prints the LAN URL to use for dist.zip after the first successful build.
Check out this article on how to write snippets.
- Create snippets for language that are not already available.
Thank you for using Acode and acode-plugin-snippets.