It has been a ‘big problem’ to me since I switched to use Mac OS from 2015, the home and end button, which are the buttons I used a lot in my daily life, behaviors are totally different than they are in Windows… It is so annoying me for a long time.
I tried to use a tool named Karabiner which makes key mapping under Mac OS. It was perfect at the beginning but I found two issues after a while. Firstly, it is a third-party tool running on the OS, which means it got a chance to fail to start in some cases. Secondly, there are so many mapping entries available in their default configuration, which would map some keys I don’t want to change. After almost a month, I stop using the Karabiner.
Finally, I found a good blog by Damieng – <Make Home & End keys behave like Windows on Mac OS X>. It describes a way to make a dict to load those key mapping by OS.
create a file called
DefaultKeyBinding.dictin your~/Library/KeyBindingsfolder (might need to create that folder too) with the following contents:{ "\UF729" = moveToBeginningOfParagraph:; // home "\UF72B" = moveToEndOfParagraph:; // end "$\UF729" = moveToBeginningOfParagraphAndModifySelection:; // shift-home "$\UF72B" = moveToEndOfParagraphAndModifySelection:; // shift-end "^\UF729" = moveToBeginningOfDocument:; // ctrl-home "^\UF72B" = moveToEndOfDocument:; // ctrl-end "^$\UF729" = moveToBeginningOfDocumentAndModifySelection:; // ctrl-shift-home "^$\UF72B" = moveToEndOfDocumentAndModifySelection:; // ctrl-shift-end }
It works to me for most of the cases.
But it doesn’t fix the mapping in the terminal, which I use for coding. It would be considered as an ‘easy’ question because it could be resolved by adding a pair of keyboard mapping in the terminal’s configuration.
go to [Terminal menu] → Preferences → Profiles tab (or settings on some versions of OS X) → Keyboard sub-tab.
Then modify/add these keys to be the following “send string to shell”
- home:
\033[H- end:
\033[F
That is it!
