Option to lock editing of individual notes

I have been playing with the Templates and Templater plugins and have managed to template my template files (write over) multiple times. Probably a mix of trying things out, setting up mobile Obsidian, and user error… but it’s frustrating.

What I’m trying to do

Lock a note so it can’t be written over or accidentally changed.

I don’t know how this could be implemented and am aware this ‘lock’ would have no meaning outside Obsidian (in the Finder, other apps accessing the file, etc), but I think this could be a useful feature.


Not the exact same use case, but certainly a good use case. Yeah, I think if a note was locked in preview mode, then you wouldn’t be able to edit it accidentally.

I accidentally wiped a template a few days ago. Like… what… how did I… crap!


I think locking notes would be a nice feature. But if I’m not mistaken, the toggle cannot reside in the YAML frontmatter. See, you would be able to enable the toggle by editing the file. But after you’ve enabled it, how do you disable it when the note is locked and you can’t switch to edit mode? You would need to open the file in an external program to remove the lock.

Perhaps not so easy to use workarounds:

  • Make the file read-only. Obsidian 0.12.12 does not recognise read-only files (at least in Windows) and it still lets you use the edit mode, but at least you will get an error message saying that saving the file has failed. The negative side is that it’s read-only in other applications too, not just Obsidian.
  • Use Git or some other version control system. Then you can run a terminal command git status to quickly see if you have made accidental changes to wrong files, and you can revert them. I know this does not substitute the ability to lock files, and version control systems do have a learning curve, if you have not used them before.
  • Obsidian itself has some File recovery functionality (a core plugin, enabled by default) in case you have some accidents. But I have never tested this myself.

Doh! Good point. The Edit lock or Preview lock would have to be a plugin overlay or part of the obsidian interface.

We could bias it toward Edit Lock Only and then Frontmatter would work, but yeah, having either a Edit Lock or Preview lock would be preferred. As the request name says Preview Lock is really the issue.

I suppose the Lock could be in the right click menu or however one button only mac people select that option.

EDIT: darn, no right click menu in Preview Mode.

Use case or problem

I have certain notes that I always want to see the preview for. I don’t need to edit them.

As an example, if I have a note with dataview on it - I’ll always want to open it as a preview as default. Another example is if I have “completed” a note - I’ll always want to open it as preview.

Proposed solution

Be able to click “more options” on the note, select a menu item such as “set note’s default view mode” and be able to toggle between preview / edit mode.

These note specific preferences would override the default mode option in settings.

E.g. If I have it set as open all notes in editor mode (which I do), when I open a preview only note - it would open as preview.

Current workaround

Toggle / Use the shortcut to switch between editor and preview. :frowning_face:

1 Like

Please search the forum before making a new FR. I merged it here.

Just one small note about this one point in particular. Soon “Live Preview” mode is going to support dataview, as far as I understand. So that will help avoid the need to constantly switch. (I agree a mode lock would be a nice feature.)

Other related threads:

I am also regularly accidentally editing my templates.

Could this be accomplished by a plugin?

I’ve now found a solution!

Search for the community plugin “Force note view mode by front matter”

1 Like

Unfortunately, it doesn’t help with templates, because the YAML gets inserted when you use the template.

Within the template note, force the view mode by writing in the YAML.

Write: “obsidianUIMode: preview”

Then when you open that template, it will open in preview as default. The YAML insertion when you use the template on a new note isn’t relevant here

It’s very relevant here. I don’t want that YAML in every note I insert that template into. It rather defeats the point of having a template.

Ah okay, I see what you mean.

I’ve never accidentally edited any of my template notes, they just live inside a template folder. I only access that when I’m adding to or editing my templates.

I’m looking for this feature too. Did any of you find a good solution?


Wow. I just realised I replied to my own reply from seven days ago not realising it was me.


I’m pasting my comment from Disable auto-save or change frequency - #68 by Iconca here because i feel it’s directly connected. I’d love to be able do Ctrl+save a file at some point. Do a bunch of stuff to it and then, if I screwed up sth, simply close the note and be back into the last saved stage of my work. Autosave is constantly messing up things for me. Or if this isn’t possible, at list, to have an option to lock a note that i’m done working on. Ideally locking the actual content, not only the view mode. Because I would often want to see source code of the note as a reference, while not being able to destroy it. In fact I’d really, really appreciate both options. Write now I’m kind of scared to use Obsidian at all and especially for any topic really significant to me.

1 Like

I get that. There are times I like to do experiments with files and then roll back if it doesn’t work.

May I make a suggestion? You might really benefit from checking out git. Because you can save snapshots of your notes, and then roll back to versions. Some people use a plugin to auto-snapshot with git. I just do manual snapshots occasionally, and review the stuff that has changed. There is also another community plugin that lets you navigate git versions and see what changed.

Git, or any other version control software. It could help get rid of some of that fear, and give you confidence to experiment again. And if things get destroyed, you can just roll back.

(Also a good idea to be able to lock a note, even in source mode.)

1 Like

Of course I’m very grateful for suggestions I’ve thought about something like manual snapshots although it still wont prevent doing things by accident. Since all notes in a volt are often connected and influence each other. I did notice some comments about auto-snapshots. I imagine it may be a little overkill for my use, but I’ll definitely check it.
Exact science like coding and stuff it’s not my strongest point. But the amount off customization available in Obsidian is mind-blowing. It’s sth I really appreciate because I don’t absorb knowledge if things aren’t arranged exactly how I want them. So I’m definitely not giving up. Actually I’m just making a list of things about Obsidian to look up. I guess your proposition will go under nr 17 :slight_smile:

This is a feature worth implementing as the currect workaround with YAML doesn’t make any sense. I think the perfect solution would be adding an option in settings to give every note it’s own view mode.

Hi all, an easy solution for the “Accidental Save” issue is to set the template files to READ ONLY in your file system. I just tested this and when I tried to edit a template file Obsidian threw an error saying it couldn’t write to the file. Its easy to reverse this when you do want to edit the templates. And this of course could be applied to any file you don’t want changed.

Keep in mind that if you have Sync set up, this will probably create issues.