21

This is unbelievably annoying, since when I code online, there is no means of undoing, and thus retrieving the text I deleted.

2 Answers2

26

Most online text editors which support keyboard shortcuts (like the Stack Exchange editor right here!) support ⌃Z (ctrl-Z) for undo too, which won't cause any system functions to be fired.

If you want to use ⌘Z, you can remap the Undo Close Tab function off ⌘Z to something else using System Preferences → Keyboard → Shortcuts → App Shortcuts. Set Application to Safari.app, Menu Title to Undo Close Tab and Keyboard Shortcut to something other than ⌘Z.

grg
  • 201,078
  • Specifically on SE, Cmd/Z will will undo the last text operation if you have a text area currently selected, otherwise will restore a closed tab. – Tetsujin Sep 03 '17 at 09:32
  • ON Ventura, go to System Settings → Keyboard → Keyboard Shortcuts... → App Shortcuts then press the plus button and type in the menu title Undo Close Tab then remap the key. – frumbert Sep 28 '23 at 07:24
  • Geez, why does this exist?! Thanks for the answer. Of note is that in Ventura I can't find the "Undo Close Tab" option in any of the menus, so this answer is really needed just to find the command to override! – jerclarke Sep 28 '23 at 22:44
  • What you can find is "Reopen Last Closed Tab" in the History menu, which is correctly mapped to command+shift+t. That's the one people should keep! – jerclarke Sep 28 '23 at 22:45
3

If you use a language other than English and the proposed solution by grg doesn't work, specify in System Preferences > Keyboard the equivalent to "Undo Close Tab" in your language.

For example, if Safari's interface language is Russian, open a tab, close it, select the Edit menu:

screenshot of location menu title 'Undo Close Tab' in Edit.

and use the text next to CommandZ (that is, 'Отменить закрытие вкладки') instead of "Undo Close Tab".

jaume
  • 15,010