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: 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 :-)

 
3
Kudos
 
3
Kudos

Now read this

Using Postgres over SSH in Golang

In this post I will show how easy it is to connect to postgres on a server via SSH using the local SSH-AGENT or password package main import ( "database/sql" "database/sql/driver" "fmt" "net" "os" "time" "github.com/lib/pq"... Continue →