On of my developers recently switched to a Mac, and was wondering how to move the insertion point to the beginning and end of a line on the Mac (OSX doesn’t support home/end keys in the same way as Windows). I thought with so many developers switching to Apple hardware, it would be useful to post a quick run-down on the awesome text shortcuts in OSX. This is hardly an exhaustive list, but these are the ones I use regularly (brackets describe behaviour for multiple presses):
- opt-left: beginning of current word (beginning of previous word)
- opt-right: end of current word (end of next word)
- opt-up: beginning of paragraph (beginning of previous paragraph)
- opt-down: end of paragraph (end of next paragraph)
- opt-delete: delete to beginning of word (delete previous word)
- opt-forward del: delete to end of word (delete next word)
- cmd-left: move to beginning of line
- cmd-right: move to end of line
- cmd-up: beginning of document
- cmd-down: end of document
- shift with any of the above: select text. For example, cmd-opt-right selects to end of the word.
- you can also chain this, so cmd-shift-right, then shift-left would select to the end of the line, then deselect the last character (ex. leaving the semi-colon).
These last two are not really shortcuts, but the lack of support for them drives me nuts in Windows:
- down arrow on last line of text (including 1 line text fields): end of line
- up arrow on first line of text (including 1 line text fields): beginning of line
It’s worth noting that text shortcuts are much more consistent in OS X than on Windows. Virtually every app supports the same shortcuts, including things like cmd-a for select all. I hate it in XP when I want to select all the text in a dialog so I hit ctrl-a and nothing happens. You only ever encounter this in bad ports or the odd java app on Mac.
You might also want to check out Textpander, which is a great little utility that will automagically replace text shortcuts in any textfield with expanded text (or even images, etc) as you type. For example, I have it set to replace “uv\” with “public var “. Unfortunately it was purchased by another company who is overcharging for it imho ($29.99). If you hunt around a bit though, you can find a copy of the original free version.
Here’s a list of other OSX shortcuts that could be useful.