I know there is an existing shortcut to do this but I'd like to have the home key mapped to beginning-of-line instead of beginning-of-buffer.

I tried putting this in my ~/.emacs file but it seems like it is still being overwritten somehow:

(global-set-key [kp-home]  'beginning-of-line) ; [Home]
(global-set-key [home]     'beginning-of-line) ; [Home]

On that note, if anyone knows where the default keybindings are set when using emacs on FreeBSD I might be able to modify that file if it is overriding my .emacs.

EDIT: I am using FreeBSD 8.2 and accessing it through SSH/PuTTY.

This is my full .emacs file (nothing too crazy as you can see):

(keyboard-translate ?\C-h ?\C-?)

(add-to-list 'load-path "/home/sam/programs/go/go/misc/emacs/" t)
(require 'go-mode-load)

(global-set-key [kp-home]  'beginning-of-line) ; [Home]
(global-set-key [home]     'beginning-of-line) ; [Home]
  • This may or may not be related, but what OS are you using? You mention FreeBSD, but it's in a side note, so it's not entirely clear (at least to me) that it's the same as your main question.
    – Shauna
    Jun 16, 2011 at 16:57
  • Your code seems correct. Can you try a .emacs containing just these two lines?
    – maxelost
    Jun 17, 2011 at 12:18

3 Answers 3


Give this a try:

(global-set-key (kbd "<home>") 'move-beginning-of-line)
  • For my FreeBSD 9 system "<home>" does not work, but "<begin>" does. Dec 22, 2011 at 16:07

I use:

(define-key global-map [home] 'beginning-of-line)

Your way seems like it should work too. Another suggestion to help you debug the problem. Hit C-h k [home] and it should show you what home is bound to and that may also give a clue what is setting it.


You can use smart home key like in: https://stackoverflow.com/questions/145291/smart-home-in-emacs/

Complete code:

(defun my-smart-beginning-of-line ()
  "Move point to beginning-of-line. If repeat command it cycle
position between `back-to-indentation' and `beginning-of-line'."
  (interactive "^")
  (if (and (eq last-command 'my-smart-beginning-of-line)
           (= (line-beginning-position) (point)))

(global-set-key [home]     'my-smart-beginning-of-line)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.