简体   繁体   中英

How to make emacs automatically indent Python code?

I'm using emacs 24.3 and Ubuntu 12.04 LTS. How do I make emacs automatically indent lines in Python, like in IDLE? Currently, it does not do that.

Also, in general, how would I do this for any programming language, say, Java or c++?

Try electric-indent-mode . It will be ebabled by default in Emacs-24.4. But note that the version in 24.3 probably doesn't work too well in python-mode buffers.

You can try other python modes, like emacs-for-python or elpy, as given by this doc: http://wikemacs.org/index.php/Python (though the default mode works fine for me on the same config).

You can install them with package.el ( Mx package-install RET elpy RET ) and call them as explained.

用Cj打开换行符,你应该得到缩进。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM