Here’s a basic Mac text editing trick; probably everyone knows it.

If you accidentally press command-up (⌘↑) or command-down. (⌘↓) and are taken to the top or bottom of a long ream of text, undo (⌘Z) and then redo (⇧⌘Z).