medusero2 downloadsInsert text files (such as dotfiles or scripts) from your computer into the current note as fenced code blocks, with the language detected from the file name.
An Obsidian plugin that inserts a text file from your computer into the current note as a fenced code block, with the language detected from the file name.
It is handy for keeping copies of configuration files (dotfiles such as .zshrc or .gitconfig), scripts and other small text files in your notes. The block is inserted at the cursor position of the active note.
Desktop only: the plugin reads files with Node.js, which is not available in Obsidian Mobile.
main.js, manifest.json and styles.css from the latest release..obsidian/plugins/file-to-code-block/ and copy the three files into it. On some systems .obsidian is hidden; enable hidden files in your file manager to see it.In Settings → File to Code Block:
| Setting | Description |
|---|---|
| Add entry | Adds a file name → language pair (e.g. .myrc → bash). Both fields are required and the file name must be new. |
| Custom languages | The list of entries you have added. They take priority over the built-in list. |
If you enter a language that Obsidian's code highlighter does not know, the plugin shows a notice. This is only a hint: the entry is still saved, and highlighting in reading view may simply be missing.
Run File to Code Block: Insert file as code block from the command palette, then type the absolute path of the file. A leading ~ is expanded to your home directory.
.zshrc becomes bash and .gitconfig becomes ini) and your custom languages.