Friday, July 8, 2011

Re: Indent/Unindent a block

On 07/08/2011 04:25 AM, Gabor Urban wrote:
> I have a minor problem: is there a possibility to indent /
> unindent a block of code?

Of course :) Vim uses the ">" and "<" operators to shift by
'shiftwidth' and uses tabs-vs-spaces as controlled by the
'expandtab' setting:

:help >
:help 'sw'
:help 'et'

Depending on how you define your "block", you can use a variety
of Vim's motions such as using the ">" and "<" in visual-mode to
do a visual selection; using text objects; using "%" to jump to a
matching item (paren/bracket/brace); or any other motion that
covers the

:help v_>
:help aB
:help i}
:help text-objects
:help {motion}

So if you're in a "{...}" block of code, you can issue

>i}

to indent the contents of the braces.

-tim


--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: