History Report a problem
Article Edit this page Discussion

Indent a code block

From Vim Tips Wiki

(Redirected from VimTip597)
Jump to: navigation, search

Tip 597 Previous TipNext 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.


Rate this article:

Share this article:

Hubs Highlights International Sites Wikia messages
Entertainment
Gaming
Cartoons & Comics
Science Fiction
Hobbies
Sports
See all...
Grand Theft Auto
Pushing Daisies
Legend of Zelda Wiki
Terminator Wiki
Everquest II Wiki
Astronomy Wiki
German
Spanish
Chinese
Japanese
More...
Wikia is hiring for several open positions


Vote for featured Wikia!

Send this article to a friend
"Indent a code block"
 
 
Hi!

I thought you'd like this page from Wikia!

http://vim.wikia.com

Come check it out!
Send confirmation