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'm looking for the emacs equivalent of vi's ^.

How can I move my cursor to the first non-whitespace character in a line?

share|improve this question

migrated from stackoverflow.com Sep 2 '11 at 18:54

This question came from our site for professional and enthusiast programmers.

up vote 63 down vote accepted

The command is back-to-indentation, bound by default to M-m.

share|improve this answer

This is what I picked up from a previous Stack Overflow question:

(defun smart-beginning-of-line ()
  "Move point to first non-whitespace character or beginning-of-line.

Move point to the first non-whitespace character on this line.
If point was already at that position, move point to beginning of line."
  (interactive)
  (let ((oldpos (point)))
    (back-to-indentation)
    (and (= oldpos (point))
         (beginning-of-line))))
(global-set-key [home] 'smart-beginning-of-line)
(global-set-key "\C-a" '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 .