I have bound C-a to the
back-to-indentation-or-beginning-of-line function below that I got from @lunaryorn's
init.el. I recommend having a look at that init.el for more useful snippets like this.
;; Make C-a toggle between beginning of line and indentation
(defun back-to-indentation-or-beginning-of-line (arg)
"Move point back to indentation of beginning of line.
Move point to the first non-whitespace character on this line.
If point is already there, move to the beginning of the line.
Effectively toggle between the first non-whitespace character and
the beginning of the line.
If ARG is not nil or 1, move forward ARG - 1 lines first. If
point reaches the beginning or end of the buffer, stop there."
(setq arg (or arg 1))
;; Move lines first
(when (/= arg 1)
(let ((line-move-visual nil))
(forward-line (1- arg))))
(let ((orig-point (point)))
(when (= orig-point (point))
I have bound this to my minor mode key map so that it can override the
C-a bindings of all other modes (including