Mac Home and End Keys

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.

Firefox 3

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.

Terminal

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

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?


15 thoughts on “Mac Home and End Keys

  1. Yeah, agree that standard bindings for home and end are not intuitive – especially if you’ve come from a Windows environment. But I find that most Mac apps behave pretty consistently to Cmd-left/Ctrl-A (start of line), Cmd-right/Ctrl-E (end of line). Not too much of a problem once you’re used to it. Especially on MacBooks because the home and end keys need to have the fn key depressed to work anyway.

  2. Very useful. I’m maddened by the Mac mythological use of those arrow keys around the help / delete keys.

  3. You can export your preferences in Eclipse.

    File -> Export ->

    General -> Preferences

    (Next)

    [X] Choose specific preferences to export

    [X] Keys Preferences

    To preference file: /Users//Desktop/keys.epf

    (Finish)

    Thanks! this works great! I had noticed the export option in the keys preference window, but for some reason I was getting null pointer errors when I tried to use it. — popcornfarmer

  4. The Hackszine.com tip did not stop my Firefox from going back one page when hitting Cmd-Left Arrow on a MacBook. However, the Firefox extension keyconfig does help. See http://forums.mozillazine.org/viewtopic.php?t=72994
    After installing go to menu Tools, Keyconfig and choose Disable for the combination “Back – Cmd-Left”.

    To see the effect go to http://tinymce.moxiecode.com/ and from that page go to the examples. Now, hitting Cmd-Left in the editor will normally get you to the previous page, but when using Keyconfig the cursor is taken to the start of the current line.

  5. Great tip that about iTerm. The Home-End issue bugged me a lot until today and I was sick of remapping hex codes in all my programs!

    iTerm rocks.

  6. Pingback: How Bug #342564 Kills Usability on the Mac « rhoderick.org

  7. Many thanks for the Firefox and Aquamacs tips — the default behavior is quite annoying indeed. :)

  8. Pingback: How Firefox’s Command Key Bug Kills Usability on the Mac « Josh Rhoderick

  9. Pingback: How Firefox’s Command Key Bug Kills Usability on the Mac | Josh Rhoderick

Comments are closed.