C-a使用ipython-mode转到emacs中的第一个字符

时间:2011-12-07 08:09:52

标签: emacs ipython

C-a让我回到了行的开头。但是我希望C-a在编写python代码时让我回到文本的开头。

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

现在,在以print开头的行的最后,我想按C-a转到print的p,而不是行的开头。 emacs中有哪些功能?

4 个答案:

答案 0 :(得分:12)

事实上,这个 M-m 有一个直接的全局键绑定

答案 1 :(得分:1)

Drew Adams有'misc-cmds.el',它有beginning-or-indentation命令。这可能就是你要找的东西。来自docstring:

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找到它。

答案 2 :(得分:0)

我用

back-to-indentation

我将它绑定到我的.emacs中的 C-x C-a

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

答案 3 :(得分:0)

我在我的设置中做了一个小的自定义功能。当我按下C-a并且它不在缩进处时,它会回到缩进处。如果是,则转到该行的开头。

;; 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)))))