Indent a code block
From Vim Tips Wiki
(Redirected from VimTip597)
Tip 597 Previous Tip • Next Tip
Created: October 30, 2003 Complexity: intermediate Author: Marcel Preda Minimum version: 6.0 Karma: 358/114 Imported from: Tip#597
Let's say we have:
// some code
{ // start block
// some other code
// HERE IS THE CURSOR
// other code
} // end block
The command >i{ will indent the current block of lines, inside { }. The { and } are unmodified.
Using >a{ will also modify the { } lines.
Unindent (shift left) using <i{ or <a{.
[edit] Comments
With the indent options correctly defined, =% works just fine.
In a C source file, >% and <% are handy to shuffle braces.
Categories: Review | VimTip | Indenting
