Search...Search plugins and themes...
⌘K
Sign in
  • Get started
  • Download
  • Pricing
  • Enterprise
  • Account
  • Obsidian
  • Overview
  • Sync
  • Publish
  • Canvas
  • Mobile
  • Web Clipper
  • CLI
  • Learn
  • Help
  • Developers
  • Changelog
  • About
  • Roadmap
  • Blog
  • Resources
  • System status
  • License overview
  • Terms of service
  • Privacy policy
  • Security
  • Community
  • Plugins
  • Themes
  • Discord
  • Forum / 中文论坛
  • Merch store
  • Brand guidelines
Follow us
DiscordTwitterBlueskyThreadsMastodonYouTubeGitHub
© 2026 Obsidian

Code File Embed

Willian SaezWillian Saez108 downloads

Embed the contents of a vault file as a syntax-highlighted code block via a codefile fenced block.

Add to Obsidian
  • Overview
  • Scorecard
  • Updates4

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.

HealthExcellent
ReviewPassed
About
Embed a vault file's contents as a syntax-highlighted code block, inferring language from the file extension and supporting line ranges or single-line targets. Render with Obsidian's code renderer (theme and copy button preserved) and auto-update blocks when the source file is saved or renamed, with an optional clickable file-path header.
CodeFilesSyntax
Details
Current version
1.0.3
Last updated
Last month
Created
Last month
Updates
4 releases
Downloads
108
Compatible with
Obsidian 1.4.0+
Platforms
Desktop, Mobile
License
MIT
Report bugRequest featureReport plugin
Author
Willian SaezWillian Saezwilliansaez
GitHubwilliansaez
  1. Community
  2. Plugins
  3. Code
  4. Code File Embed

Related plugins

Code Space

Professional code file management with visual dashboard, syntax highlighting editor, and Markdown embedding.

VSCode Editor

Edit Code Files like VSCode.

Shiki Highlighter

Highlight code blocks with Shiki.

Notebook Navigator

A better file browser and calendar inspired by Apple Notes, Bear, Evernote and Day One.

Claudian

Embeds Claude Code/Codex and other local Agents as AI collaborators in your vault.

Advanced URI

Control everything with URI.

Local REST API with MCP

Unlock your automation needs by interacting with your notes over a secure REST API.

Find orphaned files and broken links

Find files that are not linked anywhere and would otherwise be lost in your vault. In other words: files with no backlinks.

Omnisearch

Intelligent search for your notes, PDFs, and OCR for images.

Recent Files

Display a list of recently opened files.