Alex Rivera | Logout

How can I indent a block of C code in Vim?

Asked 2009-03-11T16:29:32.030
15

Duplicate:

How to indent code in vim editor in Windows?

Tabbing selected section in VIM

Sometimes I want to indent a block of C code in Vim. I usually ended up tabbing it line by line.

What is a better/faster way?

Edit
Report

1 Answer

0

If you have unindented code that looks like this...

if (foo)
{
/* line 1 */
/* line 2 */
/* line 3 */
}

...place your cursor on "line 1" in command mode and type 3==, where 3 is the number of lines to indent.

answered 2009-03-11T16:37:02.373

Your Answer