Tip 597 Printable Monobook Previous Next

created 2003 · complexity intermediate · author Marcel Preda · version 6.0

This tip contains information about adjusting the indent of source code in a block formed by braces ({...}), such as is used in the C language.

For related information, see:

Commands to indent blocks[edit | edit source]

Suppose the indent options are correctly defined and we find this badly indented code:

int myfunction(int a)
 if ( a == 1 ) {
return 1;        // the cursor is in this line
 return 0;

These commands will fix the indents:

  • =i{ reindents "inner block" (inside the braces).
  • =a{ reindents "a block" (including the braces).
  • =2a{ reindents 2 blocks (this block and containing block).

Instead of "{", you can use "}" or "B", for example, =aB indents a block.

These commands will decrease or increase indents:

  • >i{ increase indent for inner block.
  • . repeat last change (increase indent of block again).
  • <i{ decrease indent for inner block.

With the cursor on { or }:

  • =% indents the block (including matching brace).
  • >% or <% indents or unindents the block.

Comments[edit | edit source]


  • Check advice.
  • Perhaps add more vaB, viB, >aB, >iB.
Community content is available under CC-BY-SA unless otherwise noted.