James Vega wrote: > According to the help for 'formatexpr', "When the function returns > non-zero Vim will fall back to using the internal format mechanism." > Unfortunately, this is only the case when 'formatexpr' is applied for > automatic formatting as the user types. > > This makes it hard to use something like the following because automatic > formatting will work as expected but attempts at manually applying > formatting to an email's body will result in nothing changing. > > $ cat ~/.vim/after/ftplugin/mail.vim > fun! FormatMail() > let headerRegex = 'mailHeader\%(Key\)\=\|mailSubject' > " Ignore formatting for mail headers but let normal formatting > " handle the body > if synIDattr(synID(v:lnum, 1, 1), 'name') !~# headerRegex > return -1 > endif > endfun > setl formatexpr=FormatMail() > > I was trying to do something simple like this because 'formatexpr' isn't > particularly clear on what the function is supposed to be doing. That > combined with 'formatexpr' not being used anywhere in the runtime files > that come with Vim made figuring things out rather fun. > > I've since figured it out, but in the end ignoring header formatting is > much simpler than trying to properly wrap headers. > > At any rate, the attached patch will cause manual formatting to fallback > to internal formatting if 'formatexpr' returns non-zero.
Looks OK. Perhaps you can also suggest an improvement for the help? -- hundred-and-one symptoms of being an internet addict: 212. Your Internet group window has more icons than your Accessories window. /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ download, build and distribute -- http://www.A-A-P.org /// \\\ 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
