Indent region

If you need to indent all of the lines in a region correctly (mainly useful for writing code), then select a region and use C-M-\ to indent it. TAB will often work too, but may behave differently in some modes.

Remember you can select the whole buffer with C-x h or use expand region to semantically expand your selection.

  • Aleksey Kladov

    And when automatic indentation does not work out, you could use `C-x TAB` with arrorw keys to increase/decrease indentation of a block of code manually.