strangely increased indentation after a line ending with comma

37 views
Skip to first unread message

tommm0

unread,
Mar 13, 2009, 3:40:50 PM3/13/09
to vim_use, tom...@orangemail.sk
Hi all!

At the moment, I'm writing an email message and formatting my
paragraphs
with the gqap command. And when Vim breaks a line right after a comma
during
the formatting, a strange thing happens: every line of the paragraph
that follows
this "comma ended" line has increased indent so that it begins at the
beginning
of the second word of the "comma ended" line. So I'm getting something
like this:

bla bla bla bla bla blablabla
bla ORANGE bla bla bla bla,
strangely indented line1
strangely indented line2

another SMALL paragraph asdf,
strangely indented line3
strangely indented line4

I'm not sure that the example will show exactly what I wanted. I't
ought to be
formated so, that "strangely indented line" 1 and 2 begin below the O
char
of the word "ORANGE". And "strangely indented line" 3 and 4 begin
below
the S char of the word "SMALL".

This is Vim 7.0 on windows, fo=tcroq2 and tw=70. The file type, format
expresion
and format program options are not set. I haven't found anything in
the docs that
could explain this behaviour. Nothing appropriate found in vim_use
group, on the
web or on vim-tips wiki. I have tried another format options with no
luck.
I have also tried Vim 6.2 on unix and that one does not have that
strange behaviour.

Does anybody know how could I ged rid of this strange indenting? What
is so
special on comma at the end of a plain text file?
Thanks in advance!

Tom

Happy Vimming!

Agathoklis D. Hatzimanikas

unread,
Mar 13, 2009, 4:29:49 PM3/13/09
to vim...@googlegroups.com
Hi Tom,

On Fri, Mar 13, at 12:40 tommm0 wrote:

> fo=tcroq2

Please try fo-=o

> Tom

Regards,
Ag.

Tony Mechelynck

unread,
Mar 14, 2009, 8:38:07 AM3/14/09
to vim...@googlegroups.com

The o flag is supposed to only affect the new line created by a
Normal-mode o or O command, not by hitting Return in Insert mode --
that's the r flag.

And if that doesn't work either, check (that file being current)

:verbose set indentexpr? cindent? lisp? smartindent?

(and if any of these options is not recognised, try again without it).

You might want to try

:setlocal indentexpr=

and if that isn't enough;

:setlocal nocindent

and if that isn't enough,

:setlmocal nolisp

and if that isn't enough,

:setlocal nosmartindent

Doing it one option at a time will tell you exactly what was wrong.


Best regards,
Tony.
--
The birds are singing, the flowers are budding, and it is time for Miss
Manners to tell young lovers to stop necking in public.

It's not that Miss Manners is immune to romance. Miss Manners has been
known to squeeze a gentleman's arm while being helped over a curb, and,
in her wild youth, even to press a dainty slipper against a foot or two
under the dinner table. Miss Manners also believes that the sight of
people strolling hand in hand or arm in arm or arm in hand dresses up a
city considerably more than the more familiar sight of people shaking
umbrellas at one another. What Miss Manners objects to is the kind of
activity that frightens the horses on the street ...

tommm0

unread,
Mar 29, 2009, 11:02:37 AM3/29/09
to vim_use
On Mar 14, 2:38 pm, Tony Mechelynck <antoine.mechely...@gmail.com>
wrote:
> ...
> The o flag is supposed to only affect the new line created by a
> Normal-mode o or O command, not by hitting Return in Insert mode --
> that's the r flag.
>
> And if that doesn't work either, check (that file being current)
>
> :verbose set indentexpr? cindent? lisp? smartindent?
>
> (and if any of these options is not recognised, try again without it).
>
> You might want to try
>
> :setlocal indentexpr=
>
> and if that isn't enough;
>
> :setlocal nocindent
>
> and if that isn't enough,
>
> :setlmocal nolisp
>
> and if that isn't enough,
>
> :setlocal nosmartindent
>
> Doing it one option at a time will tell you exactly what was wrong.
>
> Best regards,
> Tony.
> ...
>

Hi Ag & Tony,

thanks for your advices. So it is the 'cindent' option that causes
the
behaviour. Seeing your post, Tony, it struck me immediately.
Before that, I had been browsing the chapters on text formatting up
& down
in docs and somehow forgot to think about things like indentation
mechanisms.
So now even writing emails in vim is ok for me :-) But, by the way,
can you
see any statement on that behaviour in chapters related to C-
indenting?
I didn't find any.

Happy Vimming!

Tom

Tony Mechelynck

unread,
Mar 29, 2009, 2:10:55 PM3/29/09
to vim...@googlegroups.com
On 29/03/09 17:02, tommm0 wrote:
>
> On Mar 14, 2:38 pm, Tony Mechelynck<antoine.mechely...@gmail.com>
> wrote:
>> ...
>> The o flag is supposed to only affect the new line created by a
>> Normal-mode o or O command, not by hitting Return in Insert mode --
>> that's the r flag.
>>
>> And if that doesn't work either, check (that file being current)
>>
>> :verbose set indentexpr? cindent? lisp? smartindent?
>>
>> (and if any of these options is not recognised, try again without it).
>>
>> You might want to try
>>
>> :setlocal indentexpr=
>>
>> and if that isn't enough;
>>
>> :setlocal nocindent
>>
>> and if that isn't enough,
>>
>> :setlmocal nolisp
>>
>> and if that isn't enough,
>>
>> :setlocal nosmartindent
>>
>> Doing it one option at a time will tell you exactly what was wrong.
>>
>> Best regards,
>> Tony.
>> ...
>>
>
> Hi Ag& Tony,

>
> thanks for your advices. So it is the 'cindent' option that causes
> the
> behaviour. Seeing your post, Tony, it struck me immediately.
> Before that, I had been browsing the chapters on text formatting up
> & down
> in docs and somehow forgot to think about things like indentation
> mechanisms.
> So now even writing emails in vim is ok for me :-) But, by the way,
> can you
> see any statement on that behaviour in chapters related to C-
> indenting?
> I didn't find any.
>
> Happy Vimming!
>
> Tom

I'm not sure. Maybe one of the settings in |'cinoptions'|. But an
increased indent when breaking the line after a comma (when the line
before that doesn't itself end in a comma) is a fairly standard feature
in programming languages:

if (expression) {
func1(arg1, arg2, arg3,
computedarg(subarg1, subarg2, subarg3),
arg4, arg5, arg6);
func2(param1, param2, param3, param4, param5, param6,
param7, param8, param9);
};


Best regards,
Tony.
--
Beware of self-styled experts: an ex is a has-been, and a spurt is a
drip under pressure.

Reply all
Reply to author
Forward
0 new messages