Mac OS X Keyboard Bindings for Home and End Keys

For my work I am using a physical keyboard which has Home and End keys, having switched to a Mac only quite recently there are still things that aren’t really obvious to me yet or I still feel them annoying in regards to cursor movements.
One of the things I that has been confusing me now for quite some time is the reaction of the Home and End keys on my keyboard. Instead of moving to the beginning of the line or the end of the line and selecting it when using the Shift modifier the cursor jumped around to the beginning or the end of the file respectively.

The solution came to mind when I found out about the ~/Library/KeyBindings/DefaultKeyBinding.dict file which lets you customize the keybindings to your liking.

My customization looks like that:

{
"\UF729"  = "moveToBeginningOfLine:";
"\UF72B"  = "moveToEndOfLine:";                        
"$\UF729" = "moveToBeginningOfLineAndModifySelection:";
"$\UF72B" = "moveToEndOfLineAndModifySelection:";
}

A good reference for all customizations can be found here: web archive of http://osxnotes.net/keybindings.html

Once I had that I was quite happy for a moment but then I hit the Terminal.app and it didn’t react the way I expected at all.
Fortunately the Terminal.app has a way to handle that as well, it just doesn’t respect the DefaultKeyBinding.dict. The Terminal.app preferences allow you to modify the Keybindings.

For that you’ll need to add the shortcuts

Here is how that looks like:

TerminalAppKeyboardPreferences-AddShortcut.png

Now to make it work you have to literally press the Escape key and then a left bracket and H or F
if you made a mistake you’ll use the mouse to press the Delete one character button the backspace or delete keys won’t do you any good ;)

And this is how looks mine right now:

TerminalAppKeyboardPreferences.png

Update: For macOS Sierra

\033[1~ -  Home
\033[4~ -  End
\033[5~ -  Page Up
\033[6~ -  Page Down

I hope that helps you too :-)

 
29
Kudos
 
29
Kudos

Now read this

Meet pypa, libpypa

For quite a while, I have been playing with the thought of writing a parser for a programming language. I have never written one before and therefore I somehow had to scratch an itch in that regards. That itch however was never that much... Continue →