Close obsidian window with cmd w on mac. Close the Window When The Last Tab is Closed

+1

On Mac the obsidian behavior for cmd+w feels broken. Every other application I can think of behaves exactly like that: cmd+w closes the window, if there is nothing sensible to close inside the window

5 Likes

Throwing another voice of support on here for this - this is a big part of how I manage tabs and windows in all other applications and it would be really nice for it to work with Obsidian

1 Like

@dabai @evanjohnson @yunruse It’s completely possible to map “Close Window” to a hotkey in MacOS, Cmd-W included. This is true of any menu command in any app in MacOS. Instructions are here:

screenshot.2022-08-08T041741Z

This command will close the window of a single vault, and not close the entire app.

1 Like

BetterTouchTool can also do this. The problem with mapping Cmd + W to closing the window is that you lose the functionality of being able to close individual tabs.

2 Likes

Use case or problem

  1. Press Ctrl/Cmd + W when only one tab is open
  2. Notice it goes to a completely useless “I’m a window with no tabs open” mode
  3. This is not the correct behaviour for any Mac app.

Proposed solution

The correct behaviour for any Mac app is for the window itself to close (without the app quitting). It should essentially do what the “Close window” menu option or clicking the red “close” button does: closes the window, but brings it back up again (with the same tab open) if bring up Obsidian.

1 Like

Relevant discussion for a workaround: Command + W shortcut - #7 by John039481957

By default, Cmd-W is mapped to “Close current tab”. You can remap this yourself. And the reason (I assume) it doesn’t act in a typical Mac way is because it is a cross-platform app, and needs to be consistent across all the operating systems. (I’m not trying to discourage your feature request. But that’s why I bet it isn’t going to happen.)

In the meantime, as a workaround, if you want to close the vault window, you can map Cmd-W (or anything you like) to “Close Window” in app specific keyboard shortcuts.

This may be how you work. I have all sorts of useful side panes still open and ready to keep working.

I like it this way. Personally, I never want my vault closed just because I closed a tab. When I’ve closed all the notes I’m working on, I open a new one and keep writing. If the app is open, I want my vault open. But if I need it closed for some reason, the menu command (or the red X) is there. Or I just quit the app.

Looking at other Electron apps with tabs, the window is closeable with Cmd+w. I think the way VS Code does it is pretty nice. On closing the final tab it goes back to a general state of a window with no tabs open. Doing Cmd+w again closes the window.

I think the current way is very much an anti-pattern and this should be implemented for improved accessibility.

Please please implement this. I now have to rethink how I manage windows because of this.

4 Likes

Hey folks, I arrived at this for much the same reason other people have. We’re used to OSX applications conventions where an application closes it’s window on CMD+W when it’s got nothing displaying. This is not the same as CMD+Q, its a cheap CMD+H.

As noted by other people in this thread, other Electron apps like VSCode follow this idiom too.

I’m happy to workaround this myself using some automation as well - is there an API I can use to introspect current state in Obsidian? E.g. JSX/AppleScript/whatever? I’d like to query the app to know how many tabs/which tabs it has open

3 Likes

As mentionned by others, the missing/desired feature would be to simultaneously be able :

  • to close Obsidian window (especially when pressing ⌘+W as there is no open tab)
  • not to close Vault (for faster re-launch)

Current behaviour

  • Press ⌘+W mutiple times to close all tabs.
    Problem: Obsidian window stays open with an empty tab (as opposed to all macOS apps)

  • Press ⌘+⇧+W or click on the red “traffic light” button to close the window.
    Problem: Obsidian closes the vault, and reopening it takes (annoyingly long) loading time.

Desired behaviour

  • When no tabs are open, close window when pressing ⌘+W.
    (i.e. close window when pressing ⌘+W multiple times)

  • Do not close Vault when closing window, or add an option in settings not to close Vault.
    (i.e. close window but keep Vault open in the background to avoid loading it every time).

Current workaround

  • Press ⌘+H to hide the window (unsatisfactory)
2 Likes

I ran into the same problem. Posted a fix in another topic: Obsidian Should Close the Window When The Last Tab is Closed - #10 by joriswvanrijn

2 Likes

4 posts were split to a new topic: Obsidian Minimize on close plugin

Use case or problem

Currently Obsidian does not close the window when the last tab is closed. This is inconsistent with most macOS applications.

Proposed solution

Obsidian should either the window when the last tab is closed.

Current workaround (optional)

Currently, a user needs two separate keyboard shortcuts. CMD W to close the tab. And CMD SHIFT W to close the window.

This is inconsistent with most macOS applications where one should only need to hit CMD W a few times and then the entire window should close.

Related feature requests (optional)

This is a related feature request: Close obsidian window with cmd w on mac. Close the Window When The Last Tab is Closed

However, I believe that feature request is focusing on the keyboard shortcut whereas the real issue seems to be that unlike other macOS apps (Chrome, Sublime Text, Finder) closing the last tab does not close the window. Visual Studio Code takes a similar approach where closing the last tab doesn’t close the window immediately, but pressing CMD-W after the last tab is closed will indeed close the window.

2 Likes

I don’t care what happens on a mac, but I NEVER want to see this implemented on Obsidian in Windows or Linux.

It is a perfectly normal thing to close the current set of tabs you’re working on in order to start afresh on a new project or area of interest (which means opening other tabs immediately after all the existing ones have been closed).

It would be extremely annoying to have the entire application window close just because you clicked (or pressed a hotkey) one time too many. The user would end up having to always remember to close all tabs except one, then open the new set of desired tabs, before going back to the last unwanted tab to close it.

It also doesn’t make any sense from a UI perspective. A tab close button is to close a tab. The window has its own close button for closing the entire window. That’s literally what it’s there for.

7 Likes

Agreed on every point, and especially this. My god that would be frustrating if closing all tabs closed Obsidian!! :dizzy_face:

3 Likes

I think alternatively if we could follow the same pattern as Visual Studio Code or Arc Browser where closing the last tab actually closes the last tab and leaves an empty shell of a window.

Then on pressing CMD W a second time, it actually closes the window.

2 Likes

Please see this video of how it currently works in VS Code:

Note that this is just closing the window not closing the application.

1 Like

It’s funny with all the threads talking about slow startup times that there are people looking for ways to more easily close the app. I went so far as to remove my close button via CSS so I never accidentally exit :stuck_out_tongue_winking_eye:

@AlJohri you could easily achieve what you want with CustomJS or any of the JavaScript plugins. Set Cmd+W to point to a script and have that script send a close tab command, unless there are no open tabs, in which case send the close app command.

This behaviour depends totally on the app. And I agree with Quisquose, it’s a totally sensible thing to close all tabs through the process of working, and then open more. To close the app, you can use Cmd-Q like every other app, or to close the vault, consider remapping “Close Window” to a hotkey in MacOS:

I thought this FR existed, but it was just a help thread. Here is some previous discussion.

Great idea! I’ll give this a shot when I get a chance. If anyone else already has done something like this please do share.

1 Like

In macOS there is a difference between closing the window vs closing the application. I would like to close all of the windows but leave the application open and in focus.

That completely depends on the app. Some apps remain open without any windows. Some automatically close. Which behaviour are you asking for? If you want to close the entire app, use Cmd-Q, like every other app in MacOS.

I would like the app to remain open without any windows and use CMD W to close all of the open tabs and then the active window.

5 Likes