jyqqs79 downloadsA lightweight find and replace with a floating, semi-transparent and draggable panel. Highlights matches in the selection or the whole note as you type, supports regex and case sensitivity, and replaces with full undo support.
Select text. Invoke your configured shortcut. Type what you want to find. Press
Enter.选中文字,按下你配置的快捷键,输入想查找的内容,按
Enter。
A focused find-and-replace panel for Obsidian that removes the most annoying extra step: selected text is never copied into the query field. The selected range is highlighted in your chosen color, the Find field starts empty, and matches appear in a separate color. The configured shortcut toggles the panel, so there is no need to click the close button.
一个专注于查找替换的 Obsidian 面板,专门去掉最麻烦的多余一步:选中的文字不会被复制到查询框。选区会使用你选择的颜色高亮,查找 输入框从空白开始,命中结果会用另一种颜色显示。配置的快捷键可以切换面板开关,因此不必再手工点击关闭按钮。
A typical find-and-replace flow creates needless cleanup:
This plugin removes the middle cleanup step. The selection remains the search scope, while the query field stays empty until you type what you actually want to find.
Enter to replace the current match, or Shift+Enter to replace all matches.current/total counter update immediately.Alt+H (small batch) – select text, press the history shortcut, pick a combo, and it replaces every match in the selection in one undo step. The panel never opens.🕐 in the panel (fine tuning) – pick a combo to load it into the panel, then adjust it and press Enter / Shift+Enter as usual. Nothing is replaced by choosing.Enter – replace the current match and jump to the next one.Shift+Enter – replace all matches in scope.↑ / ↓ – move between matches without replacing.Tab – move between the find and replace fields.Esc – close the panel and clear all highlights.Ctrl+Z / Ctrl+Shift+Z works as expected. Replace-all is a single undo step.main.js, manifest.json and styles.css from the latest release.<vault>/.obsidian/plugins/search-replace-helper/.npm install
npm run build
This produces main.js, manifest.json and styles.css in the repository root. Copy them to <vault>/.obsidian/plugins/search-replace-helper/ and reload Obsidian.
There is no need to delete the selected text from the query field: it is never inserted there. Assign Find and replace to your preferred key in Settings → Hotkeys; the command toggles the panel without requiring a mouse click.
| Setting | Description |
|---|---|
| Regex by default | Interpret the find text as a regular expression by default. |
| Match case by default | Make searches case-sensitive by default. |
| Selection highlight color | Choose the color used for the selected search scope. |
| Popup opacity | Adjust transparency of the floating panel. |
| Popup font size | Adjust the font size of the floating panel. |
| Remember popup position | Reopen the panel at its last position within the session. |
| Remember find and replace history | Record each find and replace combo for reuse. |
| History entries to keep | How many recent combos to keep. Favorites are never dropped. |
| History shortcut | Shortcut that applies a combo to the selection, Alt+H by default. |
| Clear history | Remove every saved combo, including favorites. |
Each combo records the find text, the replacement, and both toggles, because ** means something very different with .* on and off. Use the 🕐 button in the panel, the history shortcut, or the Apply find and replace history to the selection command.
There are two ways to use a combo, and they do different things on purpose:
| Entry point | What picking a combo does |
|---|---|
Alt+H, or the command, with a selection active |
Replaces every match in the selection in one undo step. The panel does not open. |
🕐 in the panel |
Loads the combo into Find and Replace and changes nothing. Press Enter / Shift+Enter when you are happy with it. |
In the picker:
0 when nothing would change, and invalid when the stored pattern no longer compiles.Favorites are listed first and are never removed by the size limit.Recently used is most-recent-first, capped by History entries to keep. Applying a combo counts as using it..* and Aa badges show the toggles the combo will restore.Mod+Shift+F, to favorite the highlighted combo.Alt+H requires a selection and never falls back to the whole note – if there is no selection it just tells you to select some text. Running it twice is safe: the second run finds no matches and does nothing. A notice reports how many matches were replaced, and Ctrl+Z reverts the whole operation in one step.
A combo is recorded when you replace, replace all, or close the panel. History lives in this vault's plugin data, which Obsidian Sync will synchronize. Use Clear history to remove it.
Toggle the .* button to search with regular expressions (JavaScript syntax). The footer shows a Regex chip whenever it is on and a Selection chip whenever the search is limited to the selected text. Replacement strings support capture groups: $1, $2, …, $& (the whole match) and $$ (a literal $). In plain-text mode, \n, \t and \r in the replacement are converted to their literal characters.
Inside a selection, ^ and $ refer to the start and end of that selection, so ^## matches a heading that begins exactly where your selection starts. Trailing spaces in the pattern still count: ^一、 matches, but ^一、 only matches when a space follows the 、. When nothing matches, the footer names the likely reason: leading or trailing spaces, a pattern that looks like a regex while .* is off, or an invalid pattern.
12/2000+ when this limit is hit.npm run dev # watch mode
npm run build # production build
npm run lint # lint and type checks
See LICENSE.
传统查找替换经常带来一段没有价值的清理工作:
本插件直接去掉中间的清理步骤:选区继续作为搜索范围,查询框保持空白,你只需要输入真正想查找的内容。
Enter 替换当前命中项,或按 Shift+Enter 替换全部命中项。当前/总数,无需等待或切换窗口。Alt+H(小批量) – 选中文本,按下历史快捷键,选中一个组合,即在选区内全部替换,一步撤销,面板不会打开。🕐(微调) – 选中组合后回填 查找 / 替换 框,不做任何替换,确认后再按 Enter / Shift+Enter。Enter – 替换当前匹配项并跳到下一处。Shift+Enter – 替换作用范围内的所有匹配项。↑ / ↓ – 在匹配项之间移动(不进行替换)。Tab – 在「查找」和「替换」输入框之间切换。Esc – 关闭面板并清除所有高亮。Ctrl+Z / Ctrl+Shift+Z 都能正常撤销。其中「全部替换」是单一步骤,可一步撤销。main.js、manifest.json 和 styles.css。<vault>/.obsidian/plugins/search-replace-helper/。npm install
npm run build
构建完成后会在仓库根目录生成 main.js、manifest.json 和 styles.css。把它们复制到 <vault>/.obsidian/plugins/search-replace-helper/ 并重新加载 Obsidian 即可。
不需要再从查询框里删除选中的文字,因为它根本不会被复制进去。可在 设置 → 快捷键 中为 Find and replace 配置任意按键;命令会自动切换面板开关,无需手工点击。
| 设置项 | 说明 |
|---|---|
| 默认使用正则 | 默认将查找内容解释为正则表达式。 |
| 默认区分大小写 | 默认开启大小写敏感搜索。 |
| 选区高亮颜色 | 选择搜索范围使用的高亮颜色。 |
| 面板透明度 | 调节悬浮面板的透明度。 |
| 面板字体大小 | 调节悬浮面板的字体大小。 |
| 记住面板位置 | 在本次会话中记住并恢复面板上次的位置。 |
| 记录查找替换历史 | 记录每个查找替换组合以便复用。 |
| 保留历史条数 | 保留多少条最近记录,收藏项永不被淘汰。 |
| 历史快捷键 | 将组合应用到选区的快捷键,默认为 Alt+H。 |
| 清空历史 | 删除全部已保存的组合,包含收藏项。 |
每条记录都会保存查找内容、替换内容以及两个开关,因为 ** 在 .* 开启和关闭时是完全不同的操作。可以通过面板中的 🕐 按钮、历史快捷键,或 Apply find and replace history to the selection 命令打开。
复用方式有两种,且刻意不同:
| 入口 | 选中组合后会发生什么 |
|---|---|
Alt+H 或该命令(需已有选区) |
在选区内全部替换,一步撤销,面板不打开。 |
面板中的 🕐 |
仅把组合回填到 查找 / 替换 框,不做任何替换;确认后按 Enter / Shift+Enter。 |
在列表中:
0,保存的模式无法编译时显示 invalid。.* 和 Aa 标记表示该组合会恢复的开关状态。Mod+Shift+F,即可收藏/取消收藏当前高亮项。Alt+H 必须先有选区,且不会退化为整篇笔记——没有选区时只会提示你先选中文本。重复执行是安全的:第二次找不到匹配,不会改动任何内容。执行后会弹出提示告知替换了多少处,Ctrl+Z 可一步回退整个操作。
组合会在执行替换、全部替换或关闭面板时被记录。历史保存在当前仓库的插件数据中,会随 Obsidian Sync 同步。可通过「清空历史」删除。
点击 .* 按钮可启用正则搜索(JavaScript 语法)。启用后面板底部会显示 Regex 标记,搜索范围限制在选区时会显示 Selection 标记。替换文本支持捕获组:$1、$2、…、$&(整个匹配)以及 $$(字面量 $)。在纯文本模式下,替换文本中的 \n、\t 和 \r 会被转换为对应的字面字符。
在选区中,^ 和 $ 表示该选区的起点和终点,因此 ^## 会匹配正好从选区开头开始的标题。模式中的空格仍然有效:^一、 可以匹配,但 ^一、 只在 、 后面确实有空格时才匹配。
找不到结果时,面板会直接说明原因:模式首尾是否有空格、是否忘记打开 .*、或者正则是否无效。
12/2000+ 等格式。npm run dev # 监听模式
npm run build # 生产构建
npm run lint # lint 与类型检查
参见 LICENSE。