On 2010-09-21, Thomas Adam wrote:
> Hi all,
> 
> I am curious how other people solve this problem in Vim and whether there's
> a generic solution.
> 
> Let's say I'm editing a filetype (regardless) and the "tw" value is set to
> "78".  This works fine on new lines where I am typing new text -- when I d
> this the line I am typing wraps at 78 chars, and all is happy with world.
> 
> This falls apart though when I then decide I need to ammend an existing
> line.  As soon as I need to do that, the wrapping happens at an odd place,
> such that I then find myself having to press "gq}" to reformat the
> paragraph, because the edit I've made has made a mess of the formatting.
> 
> So my question is:  is there a way of avoiding this "gq}" step, and instead
> -- if I have to go and add more text to an existing line where there's a
> "set tw=$FOO" line applied to the file, that this is honoured automatically,
> without the need to then reformat the edited paragraph via "gq}" to get the
> formatting correct?

I've had moderate success using the 'a' and 'w' options to
'formatoptions'.  See

    :help auto-format
    :help fo-table

In addition to the warnings in the reference manual, be aware that
there is a bug in the 'a' option in recent versions of Vim that
affects the automatic formatting of _indented_ paragraphs.  The bug
was introduced by a fairly recent change, though, and I think it
will be resolved before long.

By "moderate success", I mean that it works well enough that I use
it while writing e-mail, but it seldom formatted the way I wanted it
to when I tried it in other circumstances, so I format everything
else with "gqap", etc.

Regards,
Gary

-- 
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

Reply via email to