Keystroke: ⌘+Z
This feature (sometimes known as "Go back") allows you to reverse or "un-do" most other editing operations, such as a Search & Replace or Cut & Paste whose outcome was not as planned, as well as allowing you to pull back incorrect typing or put back an incorrect deletion.
It should be noted that Undo only works during the current open session with a document. Once you close a document, regardless of whether or not you have saved it, when you reopen it Undo cannot reverse any edit done during the prior session.
As each edit is done it is "stacked up" for Undo, in case it needs to be backed out again. When Undo is invoked it always goes to the last item in the stack and reverses it. This means that sometimes you must undo several edits to reverse the one you are concerned with.
You should use Undo with some care, since there is a limit of 100 operations. However, a use of "Replace All" does count as one.