|
|
| Line 11: |
Line 11: |
| |
|category2= |
|
|category2= |
| |
}} |
|
}} |
| − |
This tip contains information about adjusting the indent of source code in a block formed by braces (<tt>{...}</tt>), such as is used in the C language. |
+ |
This tip contains information about adjusting the indent of source code in a block formed by braces (<code>{...}</code>), such as is used in the C language. |
| |
|
|
|
| |
For related information, see: |
|
For related information, see: |
| Line 31: |
Line 31: |
| |
|
|
|
| |
These commands will fix the indents: |
|
These commands will fix the indents: |
| − |
*<tt>=i{</tt> reindents "inner block" (inside the braces). |
+ |
*<code>=i{</code> reindents "inner block" (inside the braces). |
| − |
*<tt>=a{</tt> reindents "a block" (including the braces). |
+ |
*<code>=a{</code> reindents "a block" (including the braces). |
| − |
*<tt>=2a{</tt> reindents 2 blocks (this block and containing block). |
+ |
*<code>=2a{</code> reindents 2 blocks (this block and containing block). |
| |
|
|
|
| − |
Instead of "{", you can use "}" or "B", for example, <tt>=aB</tt> indents a block. |
+ |
Instead of "{", you can use "}" or "B", for example, <code>=aB</code> indents a block. |
| |
|
|
|
| |
These commands will decrease or increase indents: |
|
These commands will decrease or increase indents: |
| − |
*<tt>>i{</tt> increase indent for inner block. |
+ |
*<code>>i{</code> increase indent for inner block. |
| − |
*<tt>.</tt> repeat last change (increase indent of block again). |
+ |
*<code>.</code> repeat last change (increase indent of block again). |
| − |
*<tt><i{</tt> decrease indent for inner block. |
+ |
*<code><i{</code> decrease indent for inner block. |
| |
|
|
|
| − |
With the cursor on <tt>{</tt> or <tt>}</tt>: |
+ |
With the cursor on <code>{</code> or <code>}</code>: |
| − |
*<tt>=%</tt> indents the block (including matching brace). |
+ |
*<code>=%</code> indents the block (including matching brace). |
| − |
*<tt>>%</tt> or <tt><%</tt> indents or unindents the block. |
+ |
*<code>>%</code> or <code><%</code> indents or unindents the block. |
| |
|
|
|
| |
==Comments== |
|
==Comments== |
| |
{{todo}} |
|
{{todo}} |
| |
*Check advice. |
|
*Check advice. |
| − |
*Perhaps add more <tt>vaB</tt>, <tt>viB</tt>, <tt>>aB</tt>, <tt>>iB</tt>. |
+ |
*Perhaps add more <code>vaB</code>, <code>viB</code>, <code>>aB</code>, <code>>iB</code>. |
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
Suppose the indent options are correctly defined and we find this badly indented code:
int myfunction(int a)
{
if ( a == 1 ) {
printf("one");
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.
TO DO
- Check advice.
- Perhaps add more
vaB, viB, >aB, >iB.