views:

10068

answers:

9

I'm a Mac user and I've decided to learn Emacs. I've read that to reduce hand strain and improve accuracy the CTRL and CAPS LOCK keys should be swapped. How do I do this in Leopard?

Also, in Terminal I have to use the ESC key to invoke meta. Is there any way to get the alt/option key to invoke meta instead?

update: While the control key is much easier to hit now, the meta key is also used often enough that its position on my MacBook and Apple Keyboard also deserves attention. In fact, I find that the control key is actually easier to hit, so I've remapped my control key to act as a meta key. Does anyone have a better/more standard solution?

+29  A: 
Kyle Cronin
'Use option as meta key' does work, but this result in me not being able to type braces and pipes '[]{}|' etc since they are on Option-7 and option now... well maps to meta. Any ideas?
Martin Wickman
@wic: Don't those characters have their own keys?
Kyle Cronin
@kyle Not here in Europe. With a norwegian keyboard they are mapped to alt- 8 and 9 and alt+shift- 8 and 9.
sverrejoh
A: 

This might sound like an unuseful question to your question, but...

Why would you want to use a text editor that requires you to reconfigure your keyboard to reduce hand strain?

lajos
+4  A: 

@lajos

From what I understand, back when Emacs was first written, control was where caps lock is today on modern keyboards. To answer your question, there are enough smart people that use Emacs for me to give it serious consideration.

Kyle Cronin
+6  A: 

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

mike511
You may be on to something - I can't remember the last time I user caps lock.
Kyle Cronin
+1  A: 

(not an ergonomic keyboard, but i really like the keys' travel and feel, and Control key , Caps Lock are swapped).

http://matias.ca/osxkeyboard/index.php

Gene T
+2  A: 

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.

+3  A: 

Not sure if you're totally married to using Emacs from the terminal, but another option is to use Carbon Emacs (my favorite) and Aquamacs (very Mac-like). Carbon Emacs uses the command key for meta, this is nice because you can do Control-Meta commands just by holding Control and Command down instead of first hitting escape then the control key sequence.

Also, if you're a serious Emacs user I thoroughly recommend that you get a keyboard suited for programming (that is one that is completely reprogrammable by itself). I use a Kinesis, it's a little bit of money but they are extremely durable and quite nice.

dnolen
+1  A: 

*

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

*

option-left arrow move left one word
option-right arrow move right one word
option-delete back delete one word
shift-option-delete foward delete one word
option-up arrow move up one paragraph
option-down arrow move down one paragraph
command-left arrow move to start of current line
command-right arrow 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)
command-select text with mouse add to selection (non-contiguous)
option-drag select rectangular area (non-contiguous)
command-option-drag add rectangular area to selection
drag selection move text
option-drag selection copy text

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

chris
A: 

Personally i have setup caps lock to behave like command on the system preferences and then on my emacs init.el file have:

(setq mac-command-modifier 'ctrl)

and this lets me use caps lock as command in most osx applications and as control in emacs. works well enough for me.

Alexandre Paes