Code Fence Completer
approvedby SWHL
Suggests language identifiers and completes Markdown code fences reliably. - This plugin has not been manually reviewed by Obsidian staff.
Code Fence Completer
Code Fence Completer provides reliable language suggestions when writing Markdown code fences in Obsidian.
Features
- Suggests common language identifiers after opening backtick or tilde fences.
- Supports aliases such as
py,js, andts, while inserting canonical identifiers. - Ranks exact, prefix, substring, and fuzzy matches, then prioritizes recent languages.
- Supports custom identifiers separated by commas or new lines.
- Supports identifiers such as
c++,c#,foo-bar, andfoo.bar. - Changes or clears the language of the code block containing the cursor.
- Preserves attributes after the language in a fence info string.
- Warns when another enabled plugin provides conflicting code-block suggestions.
- Avoids opening suggestions on closing fences.
- Inserts an empty code block, or wraps the current selection, with the Insert code block command.
- Works on desktop and mobile.
Usage
Type an opening fence and start entering a language:
```type
Choose a suggestion with the keyboard or pointer. The cursor moves into the code block. If there is no matching closing fence, the plugin adds one before the following document content.
You can also assign a hotkey to Code Fence Completer: Insert code block in Obsidian's Hotkeys settings.
Aliases and fuzzy search
Built-in aliases include py=python, js=javascript, ts=typescript, sh=bash, md=markdown, yml=yaml, and cs=csharp. Add custom mappings in the plugin settings using one mapping per line or comma-separated entries:
rb=ruby
kt=kotlin
Alias matches insert the canonical language. Fuzzy matching also finds identifiers when the query is a non-contiguous subsequence, such as jvs for javascript.
Change an existing code block
Place the cursor anywhere from a code block's opening fence through its closing fence, then run Code Fence Completer: Change code block language. Choose a language to replace only the first info-string token, preserving attributes such as title=demo. Choose No language to clear the entire info string.
Conflicting plugins
Only one code-block language suggester should be enabled. The plugin warns when it detects Codeblock Completer or the previous Code Language Completer plugin enabled at the same time.
Manual installation
- Download
main.jsandmanifest.jsonfrom the latest release. - Put them in
<vault>/.obsidian/plugins/code-fence-completer/. - Reload Obsidian and enable Code Fence Completer in Community plugins.
Development
npm install
npm run check
Run npm run dev to rebuild while editing.
Release
- Run
npm version patch,npm version minor, ornpm version major. - Push the commit and version tag with
git push --follow-tags. - The release workflow builds the plugin and attaches
main.jsandmanifest.jsonto a GitHub release.
Acknowledgements
This plugin is based on stanley-910/obsidian-code-language-completer, originally released under the MIT License. This fork includes substantial reliability, usability, testing, and release-tooling updates.
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.