Sorry this is not a very exciting post, but it will probably be useful for somebody…
For some reason the people at Apple think that the Home and End keys should scroll you to the top or bottom of a document rather than the start or end of a line. After searching far and wide, I have finally found how to get back what I consider the normal functionality in a bunch of applications I regularly use: the terminal, Firefox, Emacs, and Eclipse.
Update: The authors have made a GREAT firefox extension which will handle fixing your key bindings automatically.
I have been using the Firefox 3 beta on my Mac and it has a bunch of new nice features. Unfortunately, it is a bit confused about home/end keys. To fix it, download the tookit.jar file from this blog and follow the directions on this page. It says it is designed for Firefox 3 beta 4, but it seems to work fine on beta 5 as well.
In fact, I’ve given up on the default Mac terminal – the default hot keys were inconvenient (ctrl+} to switch tabs?!) and the home/end keys didn’t work as I’d like. Now I use iTerm, which is a very nice replacement. It easily lets you set up all of the keyboard shortcuts you want for common actions and lets you bookmark a server so that when you hit a shortcut it automatically opens a new terminal with an ssh connection to the server you want. It has some other handy features like being able to “Send input to all tabs” – I often have five or six tabs open and need to run the same command on all of them. Just enable this mode and anything you type gets sent to all of your open tabs. Very handy.
Aquamacs (Fancy Emacs)
I’m not a complete fanatic about either of the emacs or vim editors, but there is a pretty good mac port of emacs called Aquamacs which I have been using. The main thing I like (which others might dislike) is that it lets you use a combination of traditional emacs key bindings, plus all of the regular Mac OS shortcuts (ie to save a file, either press apple+s or ctrl-x-s). Unfortunately it starts out with some bad keybindings for home/end. Luckily, I found this fix from Stuff & Things.
Create a .emacs file in your home directory with this text in it:
;;; for Aquamacs Emacs, they set some keys in
;;; the osx-key-mode-map, and make it a more
;;; default keymap than global-map.
(if (boundp 'osx-key-mode-map)
(setq hah-key-map osx-key-mode-map)
(setq hah-key-map global-map))(define-key hah-key-map [home] 'beginning-of-line)
(define-key hah-key-map [end] 'end-of-line)
(define-key hah-key-map [C-home] 'beginning-of-buffer)
(define-key hah-key-map [C-end] 'end-of-buffer)
Eclipse is an IDE primarily for the Java programming language, but has plugin support for C/C++ and others. It is a pretty nice development environment, but once again the mac version comes with some ridiculous key bindings. Here is how to reset them to something reasonable.
- Eclipse Menu->Preferences
- Select General->Keys
- Change bindings for:
- Next/Previous Word
- Select Next/Previous Word
- Text End/Start
- Select Text End/Start
- Line Start/End
- Select Line Start/End
Find each command using the filter/search box, then click “Remove Binding” and press the desired key sequence you would like.
Note: For some reason these preferences are specific to each workspace, so you will have to do this for every project! Anyone know a better way?