On Mon, May 15, 2006 at 03:56:25PM +0200, Jiří Černý wrote:
> Hello,
>
> I have tried to write a function for formatting TeX files using the new
> 'formatexpr' function. Goal is (of course) to keep matching dollars on
> one line and not to use the insert mapping of <space>.
>
> I have more or less found a good solution. The only problem is that this
> solution interacts quite badly with the undo mechanism of vim. The
> function I wrote uses vim internal formatting algorithm when no special
> treatment is necessary (returns 1) otherwise it does the formatting job
> and returns 0. In the second case it uses append() function to add a new
> line under the current line.
>
> I have feeling that this append() function is not recorded for the undo.
> Essentially, every use of append() for formatting during an insertion of
> a long paragraph results in one line that is left in the file after
> undoing this insertion.
>
> I can post the scripts that I use if it is necessary, but maybe the
> description is sufficient to understand the problem.
>
> It is also maybe possible to use different means to append the line, but
> I find append() to be the best one.
>
> This problem appears in VIM 7.0c10. I had no time to compile the final
> version, so sorry if this problem has been already resolved.
Please do post the script you use, simplified as much as possible,
so we can test it. I tried
:call append(line("$"), "This line brought to you by append()")
and then (in Normal mode)
u
and it worked fine. This is with vim 7.0.
An alternative is to use
:put='This line brought to you by :put'
instead of append(). I do not know whether that will work any better.
HTH --Benji Fisher