The Command+Z keyboard shortcut on a Mac undoes your last action, and pressing Shift+Command+Z redoes it. This works across nearly every Mac app, including text editing, file management in Finder, and even in design programs like Photoshop, making it one of the most useful shortcuts you can memorize.
What Command+Z Actually Does
When you press Command+Z, macOS sends an “undo” command to the frontmost application. The app then reverses the most recent change you made. For example, if you just typed a sentence in Pages or Notes, Command+Z deletes that sentence. If you accidentally moved a file into the wrong folder in Finder, Command+Z puts it back. The action is context-sensitive—it always undoes whatever you did last in that specific app.
Most Mac apps support multiple levels of undo. That means pressing Command+Z repeatedly will keep stepping backward through your recent actions, one at a time. The number of undo steps varies by app; for instance, Microsoft Word typically allows dozens of undos, while some lightweight text editors may only remember a few.
The Redo Shortcut: Shift+Command+Z
If you undo something and then change your mind, you can redo it with Shift+Command+Z. This reverses the undo, restoring the action you just canceled. The redo shortcut is the mirror image of undo on the keyboard—hold Shift, then press Command and Z together. In some apps, you can also use Command+Y as an alternative redo shortcut, but Shift+Command+Z is the standard across macOS and works in almost every program.
Redo only works if you haven’t performed any new action since the undo. If you type a new character or click a new button after undoing, the redo history is cleared, and you cannot restore the undone action.
How It Differs from Ctrl+Z on Windows
On a Windows PC, the undo shortcut is Ctrl+Z. The Mac equivalent replaces the Ctrl key with the Command key (⌘), which sits next to the space bar. The physical location of the Command key is different from Ctrl, so if you’re switching from Windows, you’ll need to adjust muscle memory. The redo shortcut also differs: Windows uses Ctrl+Y or Ctrl+Shift+Z, while Mac uses Shift+Command+Z.
Another key difference is that on Mac, the Command key is used for most menu shortcuts (like Command+C for copy, Command+V for paste), whereas Windows uses Ctrl for those. Once you internalize that Command is the primary modifier on Mac, the rest of the shortcuts fall into place.
Where Command+Z Works (and Where It Doesn’t)
Command+Z works in virtually every Apple-made app, including Safari (undo closing a tab), Mail (undo moving an email), and Preview (undo edits to a PDF). Third-party apps also support it, from Adobe Creative Suite to Slack and Visual Studio Code. However, there are a few places where it does nothing:
- In the Finder’s desktop view, you can undo file operations like delete, rename, or move, but not visual changes like icon arrangement.
- Some web apps (like Google Docs) use their own undo system, which may require the shortcut to be pressed while the document area is focused.
- Apps that don’t have an undo feature at all, such as simple games or system settings, will ignore the shortcut.
If Command+Z doesn’t work, check the Edit menu of that app—if the Undo item is grayed out, the action cannot be undone.
Undo in Terminal and Command Line
In the Terminal app, Command+Z does not undo your last typed command. Instead, it sends a SIGTSTP signal, which suspends the currently running foreground process. This is a Unix behavior, not a macOS-specific one. To undo text editing in Terminal, you use standard text-editing shortcuts like Control+U to clear the current line. If you accidentally suspend a process with Command+Z, you can bring it back to the foreground by typing fg and pressing Return.
For file operations in the command line (like rm or mv), there is no undo. This is a common misconception—once you delete a file with rm, Command+Z will not restore it. You would need a backup or a tool like Time Machine.
Customizing Undo Settings in Specific Apps
Most apps let you adjust how many undo steps they remember, though the setting is often hidden. For example, in Adobe Photoshop, you can change the number of history states in Edit > Preferences > Performance, with a maximum of 1000. In Microsoft Word, the undo limit is fixed and not user-configurable. In code editors like VS Code, you can set workbench.editor.untitled.hint or use extensions to increase undo levels.
If you find that an app only allows one or two undos, check that app’s preferences or documentation for an “undo depth” or “history” setting. Some apps also let you clear the undo history, which frees memory but means you can no longer undo previous actions.
Common Problems and Fixes
One frequent issue is that Command+Z undoes something you didn’t intend, like deleting a paragraph instead of just a word. This happens because undo works on the last complete action, which might be larger than you expected. To avoid this, save your work frequently (Command+S) so you can revert to a saved state if needed.
Another problem is that Command+Z doesn’t appear to work in certain dialog boxes or pop-up menus. In those cases, the shortcut is often captured by the system, and you need to use the on-screen buttons instead. Also, if you have an external keyboard with a Windows layout, the Command key might be mapped to the Alt key, so you’ll need to adjust the modifier key settings in System Settings > Keyboard > Keyboard Shortcuts > Modifier Keys.
If undo stops working entirely, restarting the app usually resets the undo history. In rare cases, a corrupted app state can cause undo to fail; quitting and reopening the app is the quickest fix.
Frequently Asked Questions
Can I undo a file deletion in Finder with Command+Z? Yes, if you delete a file by pressing Command+Delete (which moves it to Trash), you can press Command+Z immediately to restore it to its original location. However, if you have emptied the Trash, Command+Z will not recover the file—you would need Time Machine or a third-party recovery tool.
What is the difference between Command+Z and Command+Shift+Z? Command+Z undoes your last action, while Command+Shift+Z redoes it. Think of undo as stepping backward in time and redo as stepping forward again. If you undo three actions and then press redo three times, you return to your original state.
Does Command+Z work in all Mac apps? No, but it works in the vast majority. Apps that lack an undo feature, like simple calculators or system utilities, will ignore the shortcut. Some apps also have limited undo, such as only one step, so test it in each app to know what to expect.
How do I undo on a Mac keyboard with no Command key? If you’re using a Windows keyboard with a Mac, the Windows key usually acts as the Command key. If that doesn’t work, go to System Settings > Keyboard > Keyboard Shortcuts > Modifier Keys and remap the Option or Control key to act as Command.
Can I undo a paste action? Yes, pressing Command+Z immediately after pasting will remove the pasted content and restore the clipboard. However, if you paste and then type or click elsewhere, the undo may affect the new action instead of the paste.
Why does Command+Z sometimes undo multiple things at once? Some apps group actions together. For example, in Pages, typing a whole sentence might be treated as one undo step, so Command+Z removes the entire sentence rather than one character. This is by design to keep undo manageable.
Related
- Battery Life Calculations: How to Estimate Runtime
- Dictionary Add or Update in C#: Best Way
- Does Java Have F Strings? (And What to Use Instead)
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- Excel Conditional Formatting for Drop-Down ListsTo color an Excel drop-down selection automatically, create the list with Data Validation, then add a conditional-formatting rule…
- Google Sheets GOOGLEFINANCE Dividends: What It Can DoGoogle Sheets’ GOOGLEFINANCE function can fetch some market data, but it is not a dependable way to retrieve…
- Excel File Extension Corrupted? Causes and Safe FixesAn Excel file-extension error usually means the filename suffix, such as .xlsx, does not match the file’s actual…
- IF vs IFS in Google Sheets: Which Formula Should You Use?In Google Sheets, use IF to test one condition and return one result when it is true and…
- Excel Hotkey to Add a Row: Shortcuts and TipsIn Excel for Microsoft 365 on Windows, select a row by clicking its number, then press Ctrl+Shift++ to…
- XLOOKUP in Google Sheets: Formula, Examples & TipsGoogle Sheets has an XLOOKUP function for finding a value in one range and returning the corresponding value…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.