Code File Embed
approvedby Willian Saez
Embed the contents of a vault file as a syntax-highlighted code block via a codefile fenced block. - This plugin has not been manually reviewed by Obsidian staff.
Code File Embed (Obsidian plugin)
Embed the current contents of a vault file as a syntax-highlighted code block, instead of copy-pasting code into a fenced block.
Usage
Point a codefile block at a file. The language is inferred from the extension.
```codefile src/foo.abap
```
Line range (1-based, inclusive):
```codefile src/foo.abap:10-25
```
Single line: :10. The path can also go in the block body (first line) if you
prefer. Paths resolve like Obsidian links (relative to the current note,
shortest-unique names work).
Features
- Syntax highlighting by extension, reusing Obsidian's own renderer (theme + copy button included).
- Live update: the block re-renders when the target file is saved or renamed.
- Optional clickable header showing the file path.
- Configurable extension → language map and max file size in settings.
Development
npm install
npm run dev # watch build -> main.js
npm run build # type-check + production bundle
npm test # unit tests (parser, langMap)
Copy main.js, manifest.json, and styles.css into
<vault>/.obsidian/plugins/codefile/ to try it in a vault.
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.