README file from
GithubFocus Existing Tab
When you open a note that is already open in a tab, this plugin switches to that tab instead of opening a second copy. That includes tabs in other Obsidian windows of the same vault.
It works however you open the note: clicking a link, the quick switcher, the file explorer, search results, bookmarks, or other plugins that open files the standard way. The check runs before the new tab is drawn, so you never see a duplicate tab appear and then close.
How it differs from similar plugins
- Mononote has the same goal. It reacts after a tab has become active, so the duplicate tab is opened first and then closed, and it needs Settings → Editor → Always focus new tabs turned on. Focus Existing Tab steps in before the duplicate tab is shown and works whether or not new tabs are focused.
- Opener also switched to existing tabs, and opened PDFs in your system's default app. It is no longer maintained and its author recommends Mononote. Focus Existing Tab only handles switching tabs.
Behaviour
- Choose the search scope. In Settings → Focus Existing Tab → Search scope, choose Current tab group only, Focused window only, or All windows and tab groups (the default). The window and tab group are those where the note would open. The plugin checks that group first, then other groups in the same window, then other windows of the same vault, within your selected scope. When there is more than one match at the same level, it uses the most recently active tab. Use Current tab group only to keep the same note side by side in separate splits.
- Explicit new windows are left alone. Choosing Open in new window opens the note in that new window even if it is already open elsewhere.
- Heading and block links are applied. Opening
[[Note#Heading]]or[[Note#^block]]switches to the existing tab and scrolls to the heading or block. - The new tab is closed unseen. When a link would open a new, empty tab, that tab is closed before it is drawn. When a link would replace the note in the current tab, the current tab is left as it is.
- Requests not to focus are respected. If a command or plugin opens a note and explicitly asks not to activate it, the existing tab stays in the background.
- Only file views count. A local graph, backlinks pane or outline that tracks the note is not treated as an open copy of it.
- Back and forward history is not covered. Navigating back or forward in a tab can still show a note that is open in another tab.
Install
From Obsidian, open Settings → Community plugins → Browse, search for "Focus Existing Tab", then install and enable it.
To try a release before it reaches the community plugin directory, install BRAT, add the beta plugin ChrisDavison/focus-existing-tab, then enable Focus Existing Tab under Settings → Community plugins.
You can also install it by hand: copy main.js, manifest.json, and styles.css from the latest release into <vault>/.obsidian/plugins/focus-existing-tab/, then enable the plugin.
Limitations
The plugin wraps an internal method that Obsidian uses to open files in a tab, and finds open tabs through parts of the workspace that are not documented. A future Obsidian release could change these and stop the plugin from working. If anything unexpected happens while it searches for an open tab, the plugin steps aside and Obsidian opens the note as usual.
Development
npm install
npm run build # bundles src/main.js into main.js
npm run dev # rebuilds on change
npm test # builds and checks tab matching
Copy main.js, manifest.json, and styles.css into a test vault's .obsidian/plugins/focus-existing-tab/ folder and reload the plugin.