Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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]
share|improve this question
    
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 '11 at 16:57
    
Your code seems correct. Can you try a .emacs containing just these two lines? – maxelost Jun 17 '11 at 12:18
up vote 2 down vote accepted

Give this a try:

(global-set-key (kbd "<home>") 'move-beginning-of-line)
share|improve this answer
    
For my FreeBSD 9 system "<home>" does not work, but "<begin>" does. – goertzenator Dec 22 '11 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.

share|improve this answer

You can use smart home key like in: http://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)))
      (back-to-indentation)
    (beginning-of-line)))

(global-set-key [home]     'my-smart-beginning-of-line)
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .