Using Obsidian for code snippets and technical notes

First, search the help docs and this forum. Maybe your question has been answered! The debugging steps can help, too. Still stuck? Delete this line and proceed.

What I’m trying to do

I am wondering if anyone effectively uses Obsidian to store, manage and copy source code snippets for whatever programming language. In addition, also having a central place to store how I troubleshooted some coding or computer issue.

Things I have tried

I know dedicated programs exist for this usecase yet would be nice to use the same app than managing more tools!

Further thoughts

I understand that it is possible yet is Obsidian is the right tool for the job?
If so, how do you do it?

I’ll likely keep a separate vault for all my programming snippets I frequently use and how I resolved a technical problem instead of regoogling three months later!
I may want to take a snapshot of articles/guides I happen to frequent incase the site where I got the help from disappears!

Thanks in advance!

1 Like

Have you searched the forum? This or something similar has come up at least once before (or maybe it was on Discord).

I initially search forum posts via Google. This is the best I could find utilising the forum’s search engine.

The aforementioned OP’s question is only somewhat related.

Please forgive me in advance if I’ve missed other obvious threads!

I guess you didn’t miss anything obvious, because I wasn’t able to find the conversation(s) I was thinking of. :expressionless:

Not a system or anything fancy, but I have have a few templates with empty code blocks (10+) ready to go named code-css, code-md, code-shell, code-blank, etc.







I often embed code blocks that I use for reference mixed with memos and whatever I’m working on.

Obsidian link variables:
note: these may require an !important or just not work with some themes.


This should take care of the link color in dataview blocks…

body :is(.block-language-dataview) { 
--link-color: var(--color-green); 

Bryan Jenks one of my favorite Obsidian YouTubers decided to move his Technical Notes to Logseq to have them separate and in outline form

I am not suggesting you use Logseq, but perhaps replicate some of Bryan’s ideas in a (separate) vault using the enhanced Obsidian Quiet Outline plugin, as per Danny Hatcher

The Quiet outline community plugin adds more features to the core outline option.

The main features are:

  • Search support for the outline
  • Hide/show relevant search results
  • Regex search
  • Custom heading level switch
  • Default heading level
  • Auto heading expand
  • Add colours to the heading level
  • Ellipsis enable/disable text wrapping.

The move heading option works like the core plugin however, it changes the heading level.

PS: Logseq’s “Content” pane can be emulated by Obsidian’s “Bookmarks”.

I’m a somewhat frequent poster in this forum, and most of my answers are related to Dataview or something related to that. This kind of resembles your use case, so I’m going to present how I do that, in the hope it could prove useful for your work ahead. After that I’m going to mention a few tidbits on the general are of code snippets and technical notes.

My setup for forum posts

Most forum posts have some initial code (or query) that either needs to be rebuilt or reworked, or just handled in a different matter. They also usually need some context in the sort of notes and related metadata structure. Therefore I started out with a single folder, ForumStuff, and added one folder for each post. I did from the start separate out all of these posts into a test vault of mine, so that it’s separated from my main personal vault.

I soon realised I needed to add another level, so now a folder for answering this question (if I made one) would be ForumStuff/f57/f57673 and the main note would be something like f57673 Code snippets and technical notes. The f57673 reflects on the numeric id of this post, and a short but full link to this post are: Using Obsidian for code snippets and technical notes

So whenever I reply to a post needing code snippets, I hit a hotkey to trigger a template where it asks for the title, e.g. f57673 Code snippets and technical notes. Then the template creates the needed folders, and the main note with some basic tags and text, like the forum url.

From there on the forum post dictates the rest of the note, but it’s typical a iterative sequence of queries where I start with the original query from the post, and refine or rebuild it into something which works.

Here one could/should probably be a little more methodical and report both the use case and the issue one is trying to solve, and possibly add some tags to show this is the initial issue. And similarly, one could/should possibly add tags or structure related to the solution, and what the key learning/aspect of it are. (I’ve not done that, so far… :slight_smile: )

Another thing I’ve been thinking about doing, is to tag each forum post with the current topics. Like I could do something like: topic: dvjs, table, flatten, group_by to denote it’s a table query using Dataviewjs where it’s needed to both use FLATTEN and GROUP BY. This would allow future me to do a search on relevant terms, and get all my previous posts related to those terms. Alas, this is also something I’ve not done so far.

The key point though, is to build a structure which will survive growing to a decent size, keep references to the where or how the issue arose, and ideally some categorisation to help you look into it on a later stage.

Some various tidbits on this subject

  • I’ve already mentioned it, but keeping a link to the origin of the issue I think is vital. Similarly, also link to sources or references which helps you illustrate or understand the issue
  • If you’re using a few given sites, like,,, or similar, I’d consider doing a folder structure for each
  • Categorise or tag everything from the start, so that you’re able to re-use your information later on
  • Allow the iteration’s to build up on your notes. They can provide to be useful at a later stage, as they could cover interesting variants of the issue
  • Try keeping positive and informative titles (like the other link suggested)
  • Even though one folder per issue/subject might seem a little overkill, I still think I would do it, as that would allow for related files to kept together in a nice unit. (This might be especially useful if you’re working on something related to Obsidian and queries, or similar use cases… :slight_smile: )

Another thought I had when thinking about this, is that for me the use case of doing non-obsidian code snippets within Obsidian could become a little troublesome. This I think because code snippets usually require so much context before the code can be executed in a meaningful way, and just nice looking code isn’t that useful. However, there are (at least) two plugins, Execute Code and Code Emitter, which boasts they’re able to execute code snippets within a note, which might be worth taking a look at.

Then again, if you’re doing one folder per issue/subject, one can imagine allowing your code environment to access that folder. So you could use Visual Studio Code (VS Code) to do other stuff in that folder, whilst still using Obsidian for the bulk of the documentation. And VS Code does also have great markdown support through some plugins.

So not sure if this is helpful, but it gives a sketch of how I approach forum posts, and some thoughts related to what I’m missing and would value even more related to my code snippets (if only I got around to doing it)


I am an independent computer professional and my view is that Obsidian is the perfect tool, for me, because Obsidian has enough functionality to make it do whatever you want.

I am currently doing the exact thing you are talking about right now, building my own personal Wiki for how I resolve computer problems. I need to desensitize the vault and Ill post a copy of it at some point.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.