[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: funny bug in vim 6



On Wed, Jan 16, 2002 at 07:09:09PM +0100, martin f krafft wrote:
| typing a message to dman yesterday, i stumbled upon something funny. i
| have my vim set to wrap at 70 characters:
| 
|   set columns=80
|   set nowrap
|   set wrapmargin=10
|   set textwidth=0
|   set wrapscan
| 
| (not sure which onees are relevant, and which ones i left out.)

textwidth -- 

        Maximum width of text that is being inserted.  A longer line will be
        broken after white space to get this width.  A zero value disables
        this.  

If you have 'tw' set to 0 then no wrapping will occur automatically.

In addition, the 'formatoptions' variable controls where automatic
wrapping will be done (see :help fo-table for details on the flags).
For mail messages you'll want to wrap normal text.  For code I have
only comments automatically wrapped.

Also check the filetype of your message.  (":set ft?")  Vim is pretty
good at identifying files as type 'mail', which you can set some
autocommands for.

augroup Mail
    au!
    au FileType mail set tw=70 fo=tcrq2 nomodeline
    au FileType mail set comments+=n:\|
    " clear the old sig and go back to the beginning of the buffer
    au BufRead /tmp/mutt* normal :g/^| -- $/,/^$/-1d^Mgg
augroup END


That last autocommand clears the sig out of the message I reply to
when the buffer is read.  (put a literal 0x0d character in place of "^M").

Some other settings that may be relevant are

" enable the new filetype and indent plugins
filetype on
filetype plugin on
filetype indent on


| this beautifully works, this email is an example.
| 
| however, when i start out a line with a variable name, like so:
| 
| $HOME for instance, then vim forgets about its intentions to wrap and will just keep going.

I don't see the problem.  Did you ":set paste" prior to typing that
line?  Sometimes I set 'paste' so I can paste some already-formatted
text into a buffer, and forget to unset it afterwards.

| oops. it doesn't work if the variable name is lowercase, or if there is
| no $. moreover, it's really hard to reproduce. but it happens every now
| and then.
| 
| just thought i'd let you know :_)
| ii  vim            6.0.093-2      Vi IMproved - enhanced vi editor

:version
VIM - Vi IMproved 6.0 (2001 Sep 26, compiled Dec 12 2001 15:59:22)
Included patches: 1, 3, 2, 4-93
Compiled by wichert@tornado


-D

-- 

No harm befalls the righteous,
but the wicked have their fill of trouble.
        Proverbs 12:21



Reply to: