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

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

109 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Current View for Obsidian

Automatically control view modes (Reading, Live Preview, Source) for your notes based on smart rules and patterns.

GitHub Release Downloads CI Status License


✨ Features

πŸ“– Automatic View Mode Control

Automatically applies the right view mode when opening notes based on your rules:

  • Reading mode for documentation and finished content
  • Live Preview for active note-taking
  • Source mode for templates and technical notes

Automatic view mode switching

🎯 Flexible Rule System

Configure view modes based on:

  • πŸ“ Folder paths – All notes in Templates/ open in Source mode
  • πŸ” File patterns – Match files using RegEx (e.g., all daily notes)
  • πŸ“‹ Frontmatter – Per-note control with custom metadata field

Rules configuration in settings

πŸ”’ Quick Lock from Context Menu

Right-click any file or folder in the File Explorer or Notebook Navigator to instantly lock it to a specific view mode.

Lock view mode from context menu

🏷️ Visual Lock Indicators

See at a glance which files and folders are locked with inline icon badges:

  • πŸ“– Book icon – Locked to Reading mode
  • πŸ–ŠοΈ Pen icon – Locked to Live Preview
  • πŸ’» Code icon – Locked to Source mode

Lock icons in File Explorer Lock icons in Notebook Navigator

Lock icons in File Explorer (left) and Notebook Navigator (right)

πŸ”Œ Notebook Navigator Integration

Full support for Notebook Navigator plugin:

  • βœ… Context menu integration using official API (v1.2.0+)
  • βœ… Lock icons in both navigation pane and file list
  • βœ… Real-time updates when locking/unlocking

🧠 How It Works

View Mode Priority

When you open a note, Current View checks for view mode rules in this order:

1. File Pattern Rules  β†’  Exact path match or RegEx pattern
2. Folder Rules        β†’  Deepest matching folder wins
3. Frontmatter         β†’  Per-note override
4. Obsidian Default    β†’  Your global Obsidian setting

Example:

  • You have a folder rule: Templates/ β†’ Source mode
  • You open Templates/meeting-note.md
  • The note has frontmatter: current view: reading
  • Result: Opens in Reading mode (frontmatter wins)

πŸ“‘ Usage Examples

Frontmatter Control

Add a frontmatter field to any note for per-note control:

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

You can customize the frontmatter key in plugin settings (e.g., change it to view-mode or display).

Common Use Cases

πŸ“š Documentation vault:

# Lock all files in Docs/ to Reading mode
Folder: Docs/
Mode: reading

πŸ—“οΈ Daily notes:

# Match pattern like "2024-01-15.md"
Pattern: ^\d{4}-\d{2}-\d{2}\.md$
Mode: live

βš™οΈ Templates:

# All templates open in Source mode for editing
Folder: Templates/
Mode: source

βš™οΈ Settings

Plugin settings panel

Core Settings

Setting Description Default
Frontmatter key Which frontmatter field to read for view mode current view
Debounce timeout Delay (ms) before applying view mode to prevent rapid switching 0

Behavior Options

Setting Description Default
Ignore opened files Don't change view mode for notes already open in workspace false
Ignore force view when not in frontmatter Only apply rules if frontmatter explicitly sets a view mode false

Visual Feedback

Setting Description Default
Show explorer icons Display lock icons next to files/folders in File Explorer and Notebook Navigator true
Show lock notifications Show notice when locking/unlocking via context menu true

Rules Configuration

  • Folder Rules: Apply view mode to all notes in a folder (context menu locks write here)
  • File Patterns: RegEx patterns or exact file paths (context menu file locks write here)

πŸ“¦ Installation

From Obsidian Community Plugins (Recommended)

  1. Open Settings β†’ Community Plugins in Obsidian
  2. Click Browse and search for "Current View"
  3. Click Install, then Enable

Via BRAT

  1. Install BRAT plugin
  2. In BRAT settings, click Add Beta Plugin
  3. Enter: LucEast/obsidian-current-view
  4. Enable the plugin in Community Plugins

Manual Installation

  1. Download the latest main.js, manifest.json, and styles.css from Releases
  2. Create folder: <vault>/.obsidian/plugins/obsidian-current-view/
  3. Copy the downloaded files into this folder
  4. Reload Obsidian and enable the plugin in Settings β†’ Community Plugins

πŸ”— Compatibility

Supported Plugins

  • Notebook Navigator (v1.2.0+) – Full integration with context menus and lock icons
  • File Explorer – Native Obsidian file explorer support

Requirements

  • Obsidian v1.0.0 or higher

πŸ›  Development

Setup

git clone https://github.com/LucEast/obsidian-current-view.git
cd obsidian-current-view
npm install

Build Commands

npm run dev          # Watch mode - auto-rebuild on changes
npm run build        # Production build

Testing

npm run test         # Run unit tests once
npm run test:watch   # Watch mode during development
npm run coverage     # Generate V8 coverage report

Architecture

See CLAUDE.md for development guidelines and architecture overview.


🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes using conventional commits (git commit -m 'feat: add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ’‘ Support

If you encounter issues or have feature requests:


πŸ™ Acknowledgments

  • Built for Obsidian
  • Integrated with Notebook Navigator by Johan Sanneblad
  • Inspired by the Obsidian community's need for better view mode control

πŸ“ 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

  •  
  •  
  •  
  •