Silence28 downloadsTypora-style code block editing experience with language autocomplete, copy button, line numbers, folding, and smart select.
A code-block editing toolkit for Obsidian, inspired by the smooth code-block workflow of Typora. It adds language autocomplete, a copy button, line numbers, folding and smart selection to fenced code blocks — all inside the editor, with no modals.
```py) and pick from 411 built-in language identifiers, with fuzzy matching and highlighted matches. Add your own identifiers, override their badge abbreviations, batch-import them, or export/import the whole list as JSON.Everything can be toggled individually in Settings → Code Block Toolkit.
Once published: open Settings → Community plugins → Browse, search for Code Block Toolkit, install and enable it.
main.js, manifest.json and styles.css from the latest release.<vault>/.obsidian/plugins/code-block-toolkit/ and put the three files there.Add silence-lei/code-block-toolkit as a beta plugin in BRAT.
| Action | How |
|---|---|
| Pick a language | Type at least one character after ``` or ~~~ on an opening fence line, then choose from the suggestion list |
| Copy code | Click the copy icon at the end of the opening fence line |
| Fold / unfold | Click the arrow at the start of the opening fence line |
| Select code | Press Mod-a (Cmd-a / Ctrl-a) repeatedly, or run the command palette action |
Note: autocomplete is only offered on the opening fence line, never on a closing fence or inside an indented (nested) fence.
| Setting | Default | Description |
|---|---|---|
| Show all languages by default | on | With an empty query, list all built-in languages instead of only 25 common ones |
| Enable smart select in code blocks | on | Cycle code content → whole block → whole document |
| Show copy button | on | Copy icon on the opening fence line |
| Show line numbers | off | Gutter numbers for content lines |
| Enable code block folding | on | Arrow icon and folded header |
| Click language label to edit | off | When folded, clicking the language expands and places the caret after the language |
| Smart select hotkey | Mod-a |
CodeMirror-style key binding |
| Custom languages | — | Add / batch import / JSON import / export / reset |
Requires Node.js 18+.
npm install # install dev dependencies
npm run dev # esbuild watch mode, writes main.js
npm run build # type-check + minified production build
Source layout:
src/
main.ts plugin entry point, settings persistence, commands
settings.ts settings tab, custom language management
suggest.ts EditorSuggest implementation
languages.ts suggestion list, abbreviations, fuzzy scoring
language-metadata.ts 411 built-in languages (badge colour + abbreviation)
common-languages.ts short list used when "show all" is off
code-blocks.ts fenced-code-block parser for CodeMirror 6
i18n.ts / strings.ts English / Chinese UI text
editor/
decorations.ts fold state, header widgets, line numbers, spacer
keymap.ts smart-select key binding
cursor-guard.ts keeps the caret out of folded lines
To test locally, copy main.js, manifest.json and styles.css into <vault>/.obsidian/plugins/code-block-toolkit/ and reload Obsidian.
version in manifest.json and minAppVersion if needed, then run npm version patch (this also updates versions.json).main.js, manifest.json and styles.css to the GitHub Release.community-plugins.json.这是一个 Obsidian 代码块增强插件:输入围栏后自动补全语言(内置 411 种,支持模糊匹配与自定义语言)、一键复制代码、显示行号、折叠代码块(折叠后显示语言与行数)、以及代码块内智能全选。所有功能均可在设置中单独开关,设置界面会跟随 Obsidian 的中英文语言。手动安装方式见上文的「Manually」小节。
MIT © silence_lei