1

Basically, I installed the latest Emacs 24.3 on my MAC OSX. I am completely new to Emacs.

Is there an equivalent of .vimrc in emacs? What is it called because I want to change the key bindings?

Problem 1: Instead of having Ctrl as C- key, I want to have CMD as C-. What is the code for this?

Problem 2: I notice that traditionally we have C- right arrow key as Slurp and C-left arrow key as barf. But on my mac, they don't work anymore and they are replaced by C-M-j and C-M-e. It took me a while to find out about this. I want to know why is it that a lot of the key bindings are so much different from Emacs on Windows? If I want the key bindings to be consistent with the ones on the Windows computer, is there a convenient way to do this or do I have to remap every single key manually?

legoscia
  • 39,593
  • 22
  • 116
  • 167
mynameisJEFF
  • 4,073
  • 9
  • 50
  • 96
  • Actually I think this question is a closer reference: http://superuser.com/questions/160150/changing-emacs-bindings-on-mac-os-x-for-command-to-be-meta especially explore the `M-x customize-group RET ns RET` settings in emacs. – bdecaf Oct 14 '14 at 11:39
  • Which Emacs is this? They behave rather differently on OSX depending on which variant you install. Try http://aquamacs.org/ if it's not what you currently have. – tripleee Oct 14 '14 at 12:03
  • Also, over here in the civilized world, Windows is hardly any yardstick for "working properly". – tripleee Oct 14 '14 at 12:03

2 Answers2

2

The emacs equivalent of the .vimrc is the so called init file which can either be ~/.emacs, ~/_emacs, or ~/.emacs.d/init.el.

You can change keybindings using the define-key, local-set-key, and global-set-key commands, check the blog post Mastering Key Bindings in Emacs for a more complete introduction.

Basically, if you want to change the key Ctrl + f to open a file, you have to add

(global-set-key (kbd "C-f") 'find-file)

to your config.

You might want to check the SO question "Emacs on Mac OS X Leopard key bindings" for help on Problem 1 (using Command as Ctrl).

I'm not completely sure what your second problem is, but as far as I know, there is no way to tell emacs to gather system global keybindings and use them internally. Hence, if you OS has some set of keybindings which you'd like to mirror in emacs, you need to remap them manually.

Community
  • 1
  • 1
elemakil
  • 3,681
  • 28
  • 53
0

Problem 2: I notice that traditionally we have C- right arrow key as Slurp and C-left arrow key as barf. But on my mac, they don't work anymore

With emacsformacosx on OSX 10.10.5, I can slurp and barf with these key sequences:

C-)   (slurp)  
C-}   (barf)  

M-(   (wrap)

Here's an example from "Clojure for the Brave and True":

Suppose you have this:

(+ 1 2 3 4)

and you want to get this:

(+ 1 (* 2 3) 4)

First, place the cursor("the point") here:

(+ 1 |2 3 4)

(The 2 will be highlighted.)

Then hit M-( (that's Option+Shift+9) to wrap the 2 in parentheses:

(+ 1 (|2) 3 4)

Then type the * and a space:

(+ 1 (* |2) 3 4)

To slurp the 3, hit C-) (that's Control+Shift+0):

(+ 1 (* |2 3) 4)

To barf the 3, place the cursor anywhere inside the inner parentheses and hit C-} (that's Control+Shift+] ):

(+ 1 (* 2) 3 4)
7stud
  • 46,922
  • 14
  • 101
  • 127