So I've decided to try emacs, and I find it really good. However, I'm mostly writing Python, so the indentation is a crucial thing for me. After couple of failures in configuring I've finally reached to the point when I press ENTER, it goes to new line and automatically indents it (with TAB - size 4). Okay. But lets say I've got a function and a loop inside it. If I want emacs to indent a for loop it does it not in a proper way (for me):
int main() { for (int i=0; i<=10; i++) { printf("lol\n"); } } cuz I want it to be:
int main() { for (int i=0; i<=10; i++) { printf("lol\n"); } } My .emacs file looks like this:
(load-theme `wombat) (setq-default standard-indent 4) (mouse-wheel-mode t) (setq make-backup-files nil) (line-number-mode 1) (setq indent-size 4) (setq-default tab-width 4) (setq-default indent-tabs-mode t) (setq-default indent-line-function 'insert-tab) (defvaralias 'c-basic-offset 'tab-width) (defvaralias 'cperl-indent-level 'tab-width) (require 'package) (add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t) Is there a way I can configure this, to make it like I want it to be?
"linux"(instead of the default"gnu"), via c-set-style. It's been a while since I played with this, so I'll leave it to someone else to answer. It's documented somewhere in the cc-mode manual.C-c C-sto check the syntax as it appears to emacs. Then you can use the functionc-set-offsetto change the indentation for that bit of syntax.