On 15-Mar-2014 Andre Sihera <andre.sih...@hotmail.co.jp> wrote:
> Hi all,
> 
> I have found an annoyance with the tab indenting (SHIFT + '>', SHIFT
> + '<') and
> was wondering if this was by design or should be fixed.
> 
> My .vimrc contains the following:
> 
>     set ts=4
>     set shiftwidth=4
> 
> So, when I visually select a block of text and press SHIFT + '>' it
> will insert
> a tab on the left on each line and the block moves four characters
> to the right.
> 
> However, this feature does not honour leading whitespace within each
> line. I use a
> mixture of tabs and whitespace to ensure that my code looks uniform
> on all platforms
> no matter what the tab size. However, the tab indent breaks this.
> For example,
> if I have the following text at ts=4 (a full stop "." character
> indicates a space):
> 
> TAB>sprintf(szSomeVariable,
> TAB>........"Some text %i, %i, %i, %i\n",
> TAB>........some_very_long_expression_that_takes_up_most_of_the_line_#1,
> TAB>........some_very_long_expression_that_takes_up_most_of_the_line_#2,
> TAB>........some_very_long_expression_that_takes_up_most_of_the_line_#3,
> TAB>........some_very_long_expression_that_takes_up_most_of_the_line_#4);
> 
> and I visually highlight the above block and press SHIFT + '>', I
> would expect
> it to look as follows:
> 
> TAB>TAB>sprintf(szSomeVariable,
> TAB>TAB>........"Some text %i, %i, %i, %i\n",
> TAB>TAB>........some_very_long_expression_that_takes_up_most_of_the_line_#1,
> TAB>TAB>........some_very_long_expression_that_takes_up_most_of_the_line_#2,
> TAB>TAB>........some_very_long_expression_that_takes_up_most_of_the_line_#3,
> TAB>TAB>........some_very_long_expression_that_takes_up_most_of_the_line_#4);
> 
> However, it actually looks like this:
> 
> TAB>TAB>sprintf(szSomeVariable,
> TAB>TAB>TAB>TAB>"Some text %i, %i, %i, %i\n",
> TAB>TAB>TAB>TAB>some_very_long_expression_that_takes_up_most_of_the_line_#1,
> TAB>TAB>TAB>TAB>some_very_long_expression_that_takes_up_most_of_the_line_#2,
> TAB>TAB>TAB>TAB>some_very_long_expression_that_takes_up_most_of_the_line_#3,
> TAB>TAB>TAB>TAB>some_very_long_expression_that_takes_up_most_of_the_line_#4);
> 
> i.e., ViM is being too clever and compressing all my whitespace into
> tabs when I
> didn't ask it to.
> 
> Is this by design? Has it been fixed since my ancient version of ViM
> (7.3.475)?
> Did I miss something in the docs? Or is this just a "feature"?
> 
> Regards,
> 
> Andre Sihera.
> 
> -- 
> -- 
> You received this message from the "vim_dev" 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
> 
> --- You received this message because you are subscribed to the
> Google Groups "vim_dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to vim_dev+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

I believe what you are trying to achieve is what I did in the patch 
I posted 4 years ago here:
https://groups.google.com/forum/#!msg/vim_dev/JDLJgDk-ZrQ/nROMNPdwfhwJ

I added an option called 'tabindent'.  The patch was ignored but I've 
been using it happily ever since.

This:
#v+
void func()
{
TAB>if (opta)
TAB>TAB>while (optb)
TAB>TAB>TAB>if (optc)
TAB>TAB>TAB>TAB>printf("opta == %d, optb == %d, optc == %d\n",
TAB>TAB>TAB>TAB>TAB>...opta,
TAB>TAB>TAB>TAB>TAB>...optb,
TAB>TAB>TAB>TAB>TAB>...optc);
}
// vim: ft=c ts=4 sw=4 cino=(0,l1
#v-

will be indented as follows:
#v+
void func2()
{
TAB>if (opta)
TAB>TAB>while (optb)
TAB>TAB>TAB>if (optc)
TAB>TAB>TAB>TAB>printf("opta == %d, optb == %d, optc == %d\n",
TAB>TAB>TAB>TAB>.......opta,
TAB>TAB>TAB>TAB>.......optb,
TAB>TAB>TAB>TAB>.......optc);
}
// vim: ft=c ts=4 sw=4 cino=(0,l1 tabindent
#v-

It works with indenting C/C++.  It allows indent scripts to be adjusted 
with a trivial modification.

You might try applying the patches attached to the message I posted 
a link to.  If the patch doesn't apply cleanly (well, I know it doesn't) 
and fixing it is difficult, I can send you a version that applies to 
current Vim.  Unfortunately, I'm quite busy for the next 2 weeks so it 
will take a bit of time.

HTH,
Lech

-- 
-- 
You received this message from the "vim_dev" 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

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui