Quick newbie question. Let's say I have the following code in Vim:
void main()
{
int i = i + 1;
return i;
}
I have the cursor on the empty line between the two lines of code. When I press i (or a) to enter text I want to cursor to indent to the right position (i.e. below the i in "int i..."). Any ideas how it can be done?
Like @chaos mentioned, cindent is probably what you're looking for.
There's also autoindent, smartindent, and indentexpr, which are all quite configurable and documented at the Vim documentation on indent.
Here's a snippet of how configurable they can be:
{N Place opening braces N characters from the prevailing indent.
This applies only for opening braces that are inside other
braces. (default 0).
cino= cino={.5s cino={1s
if (cond) if (cond) if (cond)
{ { {
foo; foo; foo;
:set cindent
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With