README file from
GithubFeatures
- Native syntax highlighting — uses Obsidian's built-in
MarkdownRenderer, so colors always match your current theme - Automatic extension registration —
.py,.ts,.js,.sh,.rs,.go, and 50+ more extensions open directly in Code Viewer - Line numbers — optional gutter with configurable line numbers
- Zero dependencies — no external libraries at runtime, only Obsidian APIs
- Read-only by design — prevents accidental edits to source files
- Optional code editing — edit source files in-place via a temporary markdown file, with save and view controls
- Declarative settings — uses Obsidian 1.13+ settings API for native search and consistency
- Multi-language UI — English, 中文, Русский support
Usage
- Install and enable the plugin
- Click any supported file (
.py,.ts,.sh, etc.) in the file explorer - The file opens in a read-only Code View with syntax highlighting
- Click the edit button (top-right) to create a temporary
.mdfile for editing - Use Save and View buttons in the editor to sync changes back
You can customize which extensions are handled via Settings → Code Viewer.
Settings
| Setting | Default | Description |
|---|---|---|
| File extensions | 50+ extensions | Comma-separated list of file extensions to open with Code Viewer |
| Show line numbers | On | Toggle the line number gutter |
| Enable code editing | On | Show the edit button for inline source editing |
| Edit open mode | Current tab | Where the editor opens: current tab or a new tab |
Requirements: Obsidian 1.13.0 or later.
Note: Changing the extension list requires reloading Obsidian (Ctrl+R) to take effect.
Supported Languages
Python, PowerShell, Bash, TypeScript, TSX, JavaScript, JSX, C#, C, C++, SQL, YAML, TOML, Rust, Go, Lua, GDScript, Batch, Ruby, PHP, Perl, R, Dart, Kotlin, Swift, Vue, Svelte, INI, XML, HTML, CSS, SCSS, Less, JSON, JSON5, HCL, Protobuf, GraphQL, and more.
Installation
From the Official Community Plugin Market (Recommended)
- Open Obsidian and go to Settings → Community plugins
- Turn off Safe mode
- Click Browse and search for "Code Viewer"
- Click Install, then Enable
Manual Installation
- Download the latest
main.js,manifest.jsonandstyles.cssfrom Releases - Create a
code-viewerfolder in your vault's plugin directory (e.g.YourVault/.obsidian/plugins/code-viewer/) and place the three files inside - Enable the plugin in Settings → Community plugins
Install via BRAT (Recommended for Testers)
- Install the BRAT plugin
- Open BRAT settings and click Add Beta plugin
- Enter
TracingOrigins/obsidian-code-viewer-plugin - Enable the plugin
Development Guide
-
Clone the repository:
git clone https://github.com/TracingOrigins/obsidian-code-viewer-plugin.git cd obsidian-code-viewer-plugin -
Copy
.env.exampleto.envand setVAULT_PATHto your Obsidian vault path:VAULT_PATH=C:/Users/YourName/Documents/MyVault -
Install dependencies and start developing:
npm install # install dependencies npm run dev # watch mode (auto-deploys to vault) npm run build # production build (auto-deploys to vault) npm run lint # run eslint
Support & Feedback
If this plugin helps you, please consider:
- ⭐ Star the repository
- 🐛 Report bugs using the bug report template
- 💡 Request features using the feature request template
- ❓ Ask questions or share ideas in GitHub Issues
- 📝 Read the contributing guide and contribute code or docs
- 💰 Donate to the developer at the support page (if available)