Gary Johnson wrote:

> On 2021-12-06, Bram Moolenaar wrote:
> > > On So, 05 Dez 2021, Gary Johnson wrote:
> > > 
> > > > On 2021-11-18, Bram Moolenaar wrote:
> > > > > Patch 8.2.3615
> > > > > Problem:    When re-formatting with an indent expression the first 
> > > > > line of a
> > > > >             paragraph may get the wrong indent. (Martin F. Krafft)
> > > > > Solution:   Apply the correct indenting function for the first line.
> > > > >             (Christian Brabandt, closes #9150, closes #9056)
> > > > > Files:      src/textformat.c, src/testdir/test_indent.vim
> > > > 
> > > > This new behavior is a bug.  It has made vim less useful.
> > > > 
> > > > When I want to format, I want to format.  When I want to indent,
> > > > I want to indent.  I don't want formatting, e.g., gq, to also
> > > > indent.
> > > > 
> > > > I frequently have text that I have manually indented to my liking,
> > > > and I then want to format it so that the lines are properly wrapped.
> > > > I want those lines wrapped according to the current indentation, not
> > > > the current indentation rules.  If I want it indented according to
> > > > the current indentation rules, I will indent it with = first.
> > > > 
> > > > Please fix this.
> > > 
> > > The old behaviour already applied the indenting settings to all lines 
> > > *except* for the very first line, which caused inconsistent indented 
> > > lines. The patch simply makes sure to also apply the indenting to the 
> > > very first line.
> > > 
> > > I was also a bit confused that indenting applied to lines being 
> > > formatted because I always thought indenting and auto-formatting are 
> > > some different features. But I believe when auto-formatting and Vim is 
> > > breaking a very long line, it does make sense to apply the indenting 
> > > settings to the line being split.
> > > 
> > > Changing this behaviour now may break other users expectations. So I am 
> > > not sure how to fix this.
> > 
> > I'm not sure why you set up auto-indenting and do not want it to be
> > applied.  Auto-indenting triggers quite often, especially when adding a
> > linke break, since then the indent for the next line has to be decided.
> > And the line before is now done, so usually it also needs the indent to
> > be recomputed.
> > 
> > I guess the auto-indenting is not doing what you want, so you would need
> > to fix how it works.
> 
> The way it used to work, the way it worked for as long as I can
> remember, was to follow the indentation of the first line.  So
> I could set the first line to whatever indentation I wanted, then
> reformat that line and any subsequent lines to have the desired
> indent, text width and comment leader.
> 
> Most of the time, Vim's auto-indenting creates the desired
> indentation, so most of the time it does do what I want.  But there
> are exceptions.
> 
> Here is a common example in C.
> 
>     foo()
>     {
>         int x;                          // Here is an end-of-line comment
>                                         // beginning at column 41 and
>                                         // extending for a few more lines.
> 
> If I want to edit that comment after the first line, or change the
> indent amount, I could do so and reformat the comment with gq
> starting on the second line.  The rest of the lines would be aligned
> under that line.  Now the indentation is shifted to be under the
> "int".

But if you try to indent the second line, or use "gq" on the first, then
it doesn't line up as you like.  This is a missing feature in 'cindent'.
Even if we fix the problem you refer to.

> The only way I know of to correct the indentation is to
> shift that line back where I want it, manually find the right place
> to break the line, break it there, then reformat the third and
> subsequent lines with gq.
> 
> Vim used to do most of that for me automatically.  At least what it
> did helped me and didn't hinder my editing.
> 
> Another example is Vim script.
> 
>     set tw=66           " Comment explaining why 66.
>     map this that
>                         " Can't put an end-of-line comment on the
>                         " same line as a mapping, so put it here.
> 
> I can't reformat that second comment anymore because Vim now insists
> on changing the indent.

True, this one can't be fixed, the indent is set manually.

> The indentation rules were pretty simple:  Vim chose a place for the
> indentation of a line.  If I didn't like that place, for whatever
> reason, I could move the indentation to where I wanted it.  Then
> I could reformat that line and any subsequent lines with gq and
> everything was good.  Now, gq re-indents the first line of the
> region, which is not its purpose, and there is no way that I know of
> to fix that.

In the second example I have to agree.

> I haven't read the initial discussion recently, but I don't really
> understand the problem with the way indentation and formatting used
> to work.  If I was just typing code or text, they "just worked".  If
> I needed to change the indentation of something, gq also "just
> worked" afterward because it reformatted according to the
> indentation of the first line of the region.
> 
> My expectation is that the behavior of gq not be broken.  Add an
> option to set the behavior if you want.  Add a plugin to change it
> if you want.  But don't change the way it has always has always been
> in a way that is not an improvement for everyone without a way to
> have the traditional behavior.

Please check issue https://github.com/vim/vim/issues/9056
This is a valid problem, when formatting several lines of text the
indent of the first line of a block is wrong, because the formatting
doesn't change it.  You can indent all the lines, but then the
formatting is wrong, the lines will be too long.

We need to have a way to indent and format at the same time.  Perhaps a
solution is to not change the indent of the very first line, since we
can assume it's either correct or the user could have set it manually.
But do indent all the lines after it.  I think that solves both
problems.

-- 
If someone questions your market projections, simply point out that your
target market is "People who are nuts" and "People who will buy any damn
thing".  Nobody is going to tell you there aren't enough of those people
to go around.
                                (Scott Adams - The Dilbert principle)

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///                                                                      \\\
\\\        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/20211206180857.C01301C0BD1%40moolenaar.net.

Raspunde prin e-mail lui