Change how home and end keys work in XCode

When I press the End key I expect it to bring me to the end of the line. Likewise when I press the Home key I expect it to bring me to the beginning of the line. In Xcode though, these navigate to the top and bottom of the page. How can this be changed?


Solution 1:

Xcode > Preferences > Key Bindings > Text Key Bindings

Then find these two:

  • Move to beginning of line
  • Move to end of line

Assign Home and End to these respectively.

If you're doing this, don't forget to update Move to Beginning/End of Line Extending Selection, too and assign ⇧ ShiftHome and ⇧ ShiftEnd, respectively. This will continue the desired behaviour when you have ⇧ Shift pressed.

You will also have to remove the conflicts that appear.

FYI: ⌘ Cmd+ and ⌘ Cmd+ are the way things are normally done on a Mac. If you are coming from Windows I would try to adjust to this. If you want to jump between words, you can use Alt+, Alt+.

Solution 2:

Go to Xcode -> Preferences... -> Key Bindings, tab Text Key Bindings, and change them to whatever you want.

Solution 3:

If you're after 'smart home', where pressing the Home key takes you to the start of the text on that line, and a second-press takes you to the start of the line... then you'll be wanting this:

https://github.com/insanehunter/XCode4_beginning_of_line