打开模式记忆
[!NOTE] 中文说明 打开模式记忆:按笔记元数据定义打开时用阅读或编辑模式,全局默认可设,性能无感。
在笔记 frontmatter 写 open-mode,打开时自动切换阅读或编辑模式;未写的笔记按全局默认。每次打开都按 frontmatter 生效,查看期间手动切换不被打回。
English description below for review purposes. / 以下为英文说明,用于过审。
Set open-mode in frontmatter to control how each note opens (reading or editing); notes without it fall back to a global default. The mode is applied every time the note opens, while manual switching is kept during the current view.
功能特性
- frontmatter 强制模式:
open-mode定义单篇笔记打开用阅读或编辑模式 - 全局默认:未设置的笔记按全局默认打开(默认阅读,可改编辑/跟随原生)
- 兼容老插件:识别 Force note view mode 的
obsidianUIMode键,旧笔记零改动迁移 - 不打扰:查看期间手动切换保持不打回;导航、后退或重新打开时按 frontmatter 重新生效
- 性能无感:事件注册延后到布局就绪,metadataCache O(1) 读取,模式相同则零操作
- 多端支持:桌面与移动端可用,不修改任何笔记数据
Features
- Per-note open mode:
open-modefrontmatter forces reading or editing view for that note - Global default: notes without
open-modefollow the global default (reading by default; editing / follow also available) - Legacy-friendly: recognizes the
obsidianUIModekey from Force note view mode, so existing notes migrate with zero changes - Non-intrusive: manual switching is kept during the current view; navigating away and reopening reapplies the frontmatter mode
- Zero-perception performance: event registration deferred to layout-ready, O(1) metadata reads, no-op when already in target mode
- Multi-platform: desktop and mobile, never modifies note data
安装
方式一:从 Obsidian 社区目录安装(推荐)
- 打开 Obsidian 设置 → 社区插件
- 点击「浏览」,搜索 "XU View Mode"
- 点击「安装」,然后「启用」
方式二:手动安装
- 从 最新 Release 下载
main.js、manifest.json、styles.css三个文件 - 在 vault 中创建目录
.obsidian/plugins/xu-view-mode/ - 将三个文件放入该目录
- 打开 Obsidian 设置 → 社区插件,找到 XU View Mode 并开启
Installation
From Obsidian Community Directory:
- Open Obsidian Settings → Community Plugins
- Click "Browse" and search for "XU View Mode"
- Click "Install", then "Enable"
Manual Installation:
- Download
main.js,manifest.json,styles.cssfrom the latest release - Put them in
<vault>/.obsidian/plugins/xu-view-mode/ - Enable in Settings → Community Plugins
使用方法
什么是 frontmatter?
就是笔记最顶部两条 --- 之间的那块区域。没有的话,在笔记第一行上方手写两条 --- 即可。
第一步:给笔记加上 open-mode
在笔记最顶部写:
---
open-mode: edit
---
保存后,重新打开这个笔记 → 自动进入编辑模式。把 edit 改成其他支持的模式,即可改变这篇笔记的打开方式:
支持的模式
| 值 | 打开效果 | 适合场景 |
|---|---|---|
edit | 编辑模式 | 日记、草稿、打开就写 |
reading | 阅读模式 | 文档、成品笔记、只看不改 |
兼容写法(不用记,知道有就行)
其他插件的常见写法在这里同样有效,大小写均可;写错了等同于没写,按全局默认打开:
| 你写的 | 等同于 |
|---|---|
read / preview | reading |
editing / source / live | edit |
推荐统一用 edit / reading,最短最直观。
[!NOTE] 从 Force note view mode 迁移 同时兼容老牌插件 Force note view mode 的
obsidianUIMode键(取值preview/source/live)。原来笔记里写的obsidianUIMode无需批量修改即可直接生效;若与open-mode同时存在,以open-mode为准。
第二步(可选):设置全局默认
设置 → 第三方插件 → XU View Mode → 默认打开模式:
- 阅读模式(默认):所有没写
open-mode的笔记都用阅读模式打开 - 编辑模式:所有没写
open-mode的笔记都用编辑模式打开 - 跟随 Obsidian 原生设置:不干预没有
open-mode的笔记,行为和没装插件一样
单个笔记的 open-mode 永远优先于全局默认。
行为说明(怎么算"不打扰")
- 查看期间不打回:打开笔记后,你手动点右上角的「阅读/编辑」切换按钮,插件不会自动改回
- 重新打开重新生效:导航到别的笔记、点后退/前进、新标签页或重启后再打开这篇笔记 → 按 frontmatter 重新应用
- 只读不写:插件只读 frontmatter,永不修改你的笔记内容
Usage
Add the following to a note's frontmatter to control how it opens:
---
open-mode: edit
---
| Value | Opens in |
|---|---|
edit | Editing view (live preview) |
reading | Reading view |
Aliases also accepted (case-insensitive): editing / source / live (edit), read / preview (reading). Invalid values are ignored and fall back to the global default.
Migrating from Force note view mode? The legacy
obsidianUIModekey (preview/source/live) is also recognized, so your existing notes work without any changes. If both keys are present in a note,open-modetakes precedence.
Global default (Settings -> XU View Mode): Follow Obsidian default / Reading / Editing. Per-note frontmatter always wins. The mode is applied each time the note opens; manual switching is kept while staying on the note.
设置说明
| 设置项 | 说明 |
|---|---|
| 界面语言 | 中文 / English 切换 |
| 默认打开模式 | 阅读模式(默认)/ 编辑模式 / 跟随 Obsidian 原生设置,仅对未写 open-mode 的笔记生效 |
技术说明
- frontmatter 键
open-mode只读不写;不修改用户数据 edit切换到 live preview 形态;reading切换到阅读视图- 优先级:
open-mode>obsidianUIMode(兼容老插件)> 全局默认 > Obsidian 原生设置
致谢 / Credits
- 功能定位参考了 Current View 与 Default View Mode(仅借鉴思路,未复制代码)
许可证
MIT License - Copyright (c) 2026 旭说
For plugin developers
Search results and similarity scores are powered by semantic analysis of your plugin's README. If your plugin isn't appearing for searches you'd expect, try updating your README to clearly describe your plugin's purpose, features, and use cases.