change C-j to newline,indent,one indention back?

Alexander Schmolck a.schmolck at gmx.net
Fri Oct 18 17:41:15 EDT 2002


eugene kim <eugene1977 at hotmail.com> writes:
> hi..
> 
> i'm wondering if i can avoid hitting backspace key
> 
> for i in something :
>    for j in something:
>       statement1
>       statement2 # C-j here 
>       |<-- cursor here & i would have to do 'backspace'
>    |<-- can C-j be changed to place cursor here?
> 
> return/C-j/C-m all do the same newline-indent..

I guess adding the following to your .emacs should work (not properly
tested):

(defun my-python-key-hook ()
  (define-key py-mode-map "\C-j" '(lambda () (interactive)
                                    (py-newline-and-indent)
                                    (py-electric-backspace 1)))
(add-hook 'python-mode-hook 'my-python-key-hook)


alex



More information about the Python-list mailing list