Can a keyboard shortcut force TextEdit windows to close and discard all changes?
Is there any way I could configure TextEdit to close the window (through keyboard shortcut) without asking me if I want to save an unsaved file?
Can be another script/program configure globally when triggered with a certain shortcut or just a script for TextEdit.
The reason for doing it is that I have a lot of temporary notes in TextEdit's window and I want to close them as fast as possible.
Solution 1:
tell application "TextEdit" to close (windows where name of its document is "Untitled") saving no
would close the "Untitled" document without saving it, tell application "TextEdit" to close every document saving no
would do the same for all open documents.
You could close the current window with tell application (path to frontmost application as text) to close window 1 saving no
. It would close all tabs in some applications that use tabs though.
It's easier to just press ⌘W⌫ in my opinion. You can disable the animation for showing the sheets with defaults write -g NSWindowResizeTime -float 0.001
.
Solution 2:
If you hit cmd+option+q to quit the app (or hold down Option while quitting from the main menu), it will give you the option to discard changes in all unsaved windows at once, rather than having to tell it to discard changes in each window individually. This will work with all Apple apps, not just TextEdit.