Emacs on Mac OS X Leopard key bindings

Swapping CTRL and CAPS LOCK

  1. Go into System Preferences
  2. Enter the Keyboard & Mouse preference pane
  3. In the Keyboard tab, click Modifier Keys...
  4. Swap the actions for Caps Lock and Control.

alt text

Using ALT/OPTION as META

  1. In the menu bar, click Terminal
  2. Click Preferences...
  3. Under the Settings tab, go to the Keyboard tab
  4. Check the box labeled Use option as meta key

alt text

That's it! You should be well on your way to becoming an Emacs master!


For reference, here are the key bindings, for moving around text:

+ - move left one word
+ - move right one word
+ delete - back delete one word
Shift + + delete - foward delete one word
+ - move up one paragraph
+ - move down one paragraph
+ - move to start of current line
+ - move to end of current line
Shift + any of the above extend selection by appropriate amount

Click then drag - select text
Double-click then drag - select text, wrapping to word ends
Triple-click then drag - select text, wrapping to paragraph ends

Shift + Select text with mouse - add to selection (contiguous)
+ Select text with mouse - add to selection (non-contiguous)
+ Drag - select rectangular area (non-contiguous)
+ + drag - add rectangular area to selection
Drag selection - move text
+ drag selection - copy text

Ctrl + A - move to start of current paragraph
Ctrl + B - move left one character
Ctrl + D - forwards delete
Ctrl + E - move to end of current paragraph
Ctrl + F - move right one character
Ctrl + H - delete
Ctrl + K - delete remainder of current paragraph
Ctrl + L - center the window on the current line
Ctrl + N - move down one line
Ctrl + O - insert new line after cursor
Ctrl + P - move up one line
Ctrl + T - transpose (swap) two surrounding character
Ctrl + V - move to end, then left one character
Ctrl + Y - paste text previously deleted with Ctrl - K

Add Option to Ctrl + F or Ctrl + B to move a word instead of a character at a time.


The other answer was very complete, but additionally I'd mention I just set the caps lock key to a second control key instead of swapping them.

Also, you'll notice that the large majority of the text entry fields in Mac OS X already accept emacs keystrokes (^A beginning of line, ^E end of line, ^P, ^N, ^K, ^Y, etc)

good luck


I really like the answer provided by Kyle Cronin, but I want to add one thing - make sure you select the appropriate keyboard for this to work. If you have an external keyboard plugged into your laptop, then there are is an additional drop down box and you will need to do this for both keyboards (or at least for your external keyboard). The screen shot below shows the "Select Keyboard" dialog box - I have selected "Joint Mac Keyboard", which is MacBook's way of saying GoldTouch external keyboard - the default is the built-in keyboard.
Screen shot showing "Select Keyboard" dialog

Once I figured that out - this works great for me!


If you use emacs over an ssh connection, or through a machine not on your local computer, the page up/page down buttons scroll through the terminal buffer - in my experience, not too helpful.

You can set your page down and page up buttons to send the appropriate commands to emacs. In emacs, you can scroll through the emacs buffer like so:

  • Page Up: Ctl-v
  • Page Down: Esc-v

So, to have the terminal send these commands to emacs, follow the instructions above to alter the Alt keys for Meta. However, instead of setting the "use option as meta" option, find the "page down" and "page up" options.

Page Down

Double click the "page down" option to edit it. Change Action to "send string to shell" and enter \026 as the string. Save it.

Page Up

Double click the "page up" button to edit it. Change Action to "send string to shell" and enter \033v as the string. Save it.