Searching through the list of keyboard shortcuts and trying them out. Searching the forum.
What I’m trying to do
Close all other tabs in a tab group - not all other tabs in all tab groups.
Right clicking on a tab in a tab group with more than one tab open has the option to ‘close others’ which closes all the other tabs in the tab group. Is there a shortcut key for this, or some way to do this without using the mouse?
Linux! There is probably a way to do this with the vimrc support plugin or some kind of script, but digging so far into the internals of Obsidian is beyond my skills.
Hmm… Don’t know any good options there. In Mac you can setup a keyboard shorcut and pick some of the default menus available within Obsidian, like the Close other. (That is if I’m not totally mistaken, and understood some of the answers I found looking for an answer to this request).
I reckon something similar should exist for Linux, as well, but I’m not sure what it’s called, and how that would work.
I’m a bit unsafe today, I think, but the following dataviewjs script closes all other windows in the active tab group, it seems. Any caveats, I really don’t know, but the other windows disappear for sure.
```dataviewjs
for (let child of app.workspace.activeTabGroup.children) {
if ( !child.containerEl.className.includes('mod-active') )
child.detach()
}
```
Disclaimer: Run at your own risk!
Now, how can I attach a query/script like this to a hotkey? Do I really need have an active view open, and insert a Templater javascript template? Or is there another way, I wonder?
Just tried it in the sandbox vault, and sometimes it closes all other tabs in the group and sometimes all but one other tab, and then running it again closes the remaining other tab.
I’ll see if I can combine this with a vimrc obcommand…
The base for this script is the active view, so if that’s not set I reckon it can go a little haywire and close something unexpected. Just something I whipped together for the fun of it, but if it’s useful…