Skip to content

Automatically set the view mode (Reading, Live Preview, Source) for notes in Obsidian using folder rules, file patterns, or frontmatter.

License

Notifications You must be signed in to change notification settings

LucEast/obsidian-current-view

Repository files navigation

current-view

Automatically set the view mode (Reading, Live Preview, or Source) of notes in Obsidian based on file patterns, folder paths, or frontmatter values.

GitHub Release Downloads CI Status License


🔧 Features

  • Automatically applies a specific view mode when opening notes
  • Configure view mode defaults based on:
    • Folder path
    • File name pattern (RegEx)
    • Frontmatter metadata
  • Right-click files or folders in the file explorer to lock them to Reading/Source/Live and see an icon badge inline (icons and notices are toggleable in settings).
  • Supports:
    • reading → Preview mode
    • source → Source/Markdown mode
    • live → Live Preview mode
  • Optional settings to:
    • Ignore already opened notes
    • Avoid forcing view if frontmatter is missing
    • Debounce view-switching to improve stability
    • Show/hide file explorer lock icons
    • Show/hide lock/unlock notices

🧠 View Mode Priority

When a note is opened, the plugin checks for a configured view mode in the following order:

  1. File pattern match (e.g. all daily notes)
  2. Folder rule (e.g. all notes in Templates/)
  3. Frontmatter field (customizable key, default is current view)
  4. Obsidian default view (fallback)

📑 Frontmatter Example

current view: reading     # Options: reading, source, live

You can customize the frontmatter key in the plugin settings.


⚙️ Settings Overview

  • Frontmatter key: Controls which frontmatter field to read (default: current view)
  • Ignore opened files: Skips notes that were already open in the workspace
  • Ignore force view when not in frontmatter: Don’t override view mode unless it’s explicitly set
  • Debounce timeout: Prevents frequent re-triggering when switching between notes
  • Folder Rules: Apply view mode to all notes in a specific folder (context menu locks write here)
  • File Patterns: Use RegEx patterns to match filenames or exact file locks from the context menu
  • Explorer icons / Lock notifications: toggle UI hints and notices

📦 Installation

Obsidian

  1. Open Obsidian and go to Settings → Community Plugins.
  2. Click Browse and search for “https://github.com/LucEast/obsidian-current-view”.
  3. Click Add Plugin.

BRAT

  1. Open the BRAT plugin in Obsidian.
  2. Search for “obsidian-current-view”.
  3. Click Install next to Current View.

Manual

  1. Download the latest release from the GitHub Releases page.
  2. Extract the downloaded zip into your Obsidian vault under: .obsidian/plugins/obsidian-current-view/
  3. In Obsidian, go to Settings → Community Plugins, scroll down to Installed plugins, and toggle Current View on.

🛠 Development

Clone this obsidian-current-viewsitory and run:

npm install
npm run dev

This will watch your code and build to the main.js file on change.

Run tests with:

npm run test         # unit tests
npm run test:watch   # watch mode during development
npm run coverage     # coverage via V8

📝 License

MIT – free to use and modify.

About

Automatically set the view mode (Reading, Live Preview, Source) for notes in Obsidian using folder rules, file patterns, or frontmatter.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •