Ca go to first character in emacs using ipython-mode

C-areturns me to the beginning of the line. But I would like to bring C-ame back to the beginning of the text when writing python code.

if(test) :
    print 'this is a test' # here i want to C-a

Now, at the end of the line starting with print, I would like to click C-ato go to p print, not to the beginning of the line. What function does this in emacs?

+5
source share
4 answers

infact there is a direct global key binding for this M-m

+11
source

There is "misc-cmds.el" from Drew Adams, which has a team beginning-or-indentation. This is probably what you are looking for. From the docstring document:

Move cursor to beginning of this line or to its indentation.
If at indentation position of this line, move to beginning of line.
If at beginning of line, move to beginning of previous line.
Else, move to indentation position of this line.

http://www.emacswiki.org/cgi-bin/wiki/misc-cmds.el.

+1

back-to-indentation

C-x C-a .emacs:

(global-set-key "\C-x\C-a" 'back-to-indentation)
0
source

I made a small custom function to do this in my setup. When I press Ca and not indentation, it returns to indentation. If so, it goes to the beginning of the line.

;; Remap C-a to more useful behaviour (a press anywhere other than at the indentation preforms the effect of back-to-indetation, otherwise, the normal C-a behaviour is used.
(global-set-key (kbd "C-a") (lambda () (interactive)
                  (let ((previous-point (point)))
                   (back-to-indentation)
                (if (equal (point) previous-point) (move-beginning-of-line 1)))))
0
source

All Articles