Linux-like keyboard mappings for the Mac

This tutorial will fix several non-standard key mappings on the Mac. The fixes are listed below.

  1. Home key behavior
  2. End key behavior
  3. Page Up behavior
  4. Page Down behavior
  5. Cut, Copy, Paste, Undo, Redo, and Save Keyboard shortcuts

First you will need to create a file named ~/KeyBindings/DefaultKeyBinding.dict

On my system the full path name to the file is /Users/jon/Library/KeyBindings/DefaultKeyBinding.dict

If you do not know how to create this file, run the following commands from the console. All commands are case-sensitive!

cd ~
cd Library
mkdir KeyBindings
cd KeyBindings
nano DefaultKeyBinding.dict

Once you have DefaultKeyBindings.dict open in nano, copy & paste the following in it.


{
    /* home */
    "\\UF729"  = "moveToBeginningOfLine:";
    "$\\UF729" = "moveToBeginningOfLineAndModifySelection:";

    /* end */
    "\\UF72B"  = "moveToEndOfLine:";
    "$\\UF72B" = "moveToEndOfLineAndModifySelection:";

    /* page up/down */
    "\\UF72C"  = "pageUp:";
    "\\UF72D"  = "pageDown:";

    /* use the flippin control key */
    "^a"        = "selectAll:";          /* C-a          Select all */
    "^x"        = "cut:";                /* C-x          Cut */
    "^c"        = "copy:";               /* C-c          Copy */
    "^v"        = "paste:";              /* C-v          Paste */
    "^z"        = "undo:";               /* C-z          Undo */
    "^y"        = "redo:";               /* C-y          Redo */
    "^s"        = "save:";               /* C-s          Save */
}

Now, press Control+o to save, then Control+x to exit.

Log out and then log back in for your new settings to appear.

Cheers,
Jonathan

Tags: , , ,

One comment

Leave a comment