A powerful Obsidian plugin that automatically controls file view modes and enforces editing restrictions based on YAML frontmatter or folder-level settings. Perfect for workflows where certain files need to be protected from editing or automatically set to specific view modes.
- Automatic View Mode Control: Set files to read-only, edit, or locked modes automatically
- YAML Frontmatter Support: Control view modes per-file using frontmatter properties
- Folder-Level Settings: Apply view modes to entire folders and subfolders
- File Locking: Completely prevent editing of sensitive or reference files
- Smart Enforcement: Automatically prevents mode changes and hides edit buttons for locked files
- Temporary Unlocking: Temporarily unlock files for editing when needed
- Flexible Configuration: Customize the frontmatter property name and notification settings
The plugin automatically detects and applies view modes when files are opened, based on two priority levels:
- YAML Frontmatter (highest priority): Individual file control using a configurable property
- Folder Settings: Automatic application to all files in configured folders
The plugin continuously monitors and enforces these settings, preventing unauthorized mode changes and editing.
read
: Read-only mode - file opens in preview mode and cannot be editededit
: Edit mode using user's preferred editing style (source or live preview)edit-source
: Force source mode editingedit-preview
: Force live preview editinglock
: Completely locked - file opens in preview mode and cannot be modified
Files can be controlled at two levels:
- File-level: Using YAML frontmatter (overrides folder settings)
- Folder-level: Applied to all files in a specific folder path
- Open Obsidian Settings → Community Plugins
- Turn off Safe mode
- Click "Browse" and search for "View Mode"
- Click "Install" then "Enable"
- Go to Settings → Community Plugins → View Mode
- Configure the following options:
The YAML frontmatter property used to control view mode. Default is view_mode
.
Examples:
---
view_mode: read
---
---
ViewStyle: lock
---
---
mode: edit-source
---
Toggle whether to show notifications when view modes change. When disabled, mode changes happen silently.
Configure automatic view modes for entire folders:
- Click "+ Add folder" in the settings
- Enter the folder path (e.g., "Daily Notes", "Projects/Work")
- Select the desired view mode
- Save settings
Folder Path Examples:
Daily Notes
- applies to files in the "Daily Notes" folderProjects/Work
- applies to files in the "Projects/Work" subfolderReference
- applies to all files in the "Reference" folder
Set all files in your "Reference" folder to read-only mode:
- In settings, add folder "Reference" with mode "read"
- All files in this folder will automatically open in read-only mode
- Users cannot accidentally edit important reference materials
Protect template files from editing:
---
view_mode: lock
---
Template files will be completely locked and cannot be modified, even temporarily.
Different editing modes for different contexts:
- Work Projects folder: Set to "edit-source" for structured editing
- Personal Notes folder: Set to "edit" for flexible editing
- Archived folder: Set to "read" to prevent accidental changes
Use "lock" mode for files that are being reviewed or are in final state:
---
view_mode: lock
status: final
---
If you prefer different frontmatter properties:
- Set "Meta property name" to "ViewStyle" in settings
- Use in your files:
---
ViewStyle: edit-preview
---
You can also customize the actual values used in your YAML frontmatter:
- Go to Settings → Community Plugins → View Mode → Custom YAML Property Names
- Configure custom values for each view mode:
Default Values:
read
→ Read-only modeedit
→ Edit mode (user preference)edit-source
→ Source editing modeedit-preview
→ Live preview editing modelock
→ Locked mode
Custom Value Examples:
---
view_mode: read_only # Instead of "read"
view_mode: editing # Instead of "edit"
view_mode: source_mode # Instead of "edit-source"
view_mode: live_edit # Instead of "edit-preview"
view_mode: protected # Instead of "lock"
---
Advanced Configuration: You can set completely custom values like:
read_only
,viewing
,display_only
editing
,modify
,changeable
source_editing
,raw_edit
,code_mode
live_editing
,preview_edit
,rich_edit
locked
,protected
,immutable
,final
The plugin adds several commands to Obsidian:
- Unlock File: Temporarily unlock a locked file for editing
- Only appears when viewing a locked file
- File automatically re-locks when navigating away
- File Opening: View mode is applied immediately when files are opened
- Continuous Monitoring: Plugin checks and enforces settings every second
- Mode Change Prevention: Blocks attempts to change view modes for locked files
- Button Hiding: Edit buttons are automatically hidden for locked files
- Preview Mode Only: Locked files are forced to stay in preview mode
- Edit Prevention: All editing attempts are blocked
- Visual Feedback: Clear notifications when editing is prevented
- Command Palette: Use "Unlock File" command to temporarily unlock
- Session-Based: Unlock persists only while viewing the file
- Auto-Relock: File automatically re-locks when navigating away
Contributions are welcome! Please feel free to submit issues and pull requests.
- GitHub Issues: Report bugs or request features
- GitHub Discussions: Ask questions and share workflows
- Funding: Support development through the funding links in the plugin
- Added custom YAML property value configuration
- Users can now define custom names for each view mode
- Enhanced settings interface with organized sections
- Improved visual styling for settings
- Initial release with core view mode functionality
- YAML frontmatter support
- Folder-level view mode settings
- File locking and enforcement
- Temporary unlocking capability
- Comprehensive settings interface