On Tue, Mar 08, 2005 at 09:02:03AM -0500, Vic Gedris wrote: > Adrian: What's this about Text::AutoFormat? Tell me more... I've > been using this line in my ~/.vimrc for years which does similar(?) > formatting when I hit CTRL-J: :nmap <C-J> vipgq Well, Text::Autoformat (lowercase 'f', my mistake) is designed to wrap and otherwise format text automatically based on understanding the flow of the text. It'll recognise and properly wrap quoted sections, wrap items in bulletted lists, and try to avoid creating orphan words on the last lines of paragraphs. It does a good job in general. Unfortunately, as with a lot of text reformatting stuff, when it fails, it fails badly. Benefits: * Properly wraps bulletted lists like this one, taking text and wrapping it to the next line. * If wrapping creates too short a final line, it reduces wrap line length until the last line is large enough (or it has to give up). * Understands quoted text pretty much perfectly. * Reletters leterred or numbered bullets to run in sequence. * Willing to wrap on hyphens. Drawbacks: * Works best with editor linewrapping turned off, since it can better handle long lines than have to guess about multiple ones. * A little overzealous with the hyphen wrapping, I found. I rewrote the wrapping routine (attached), but I don't think I quite did it right, since when it *dewraps* a break, I occasionally get a double space. Also, dewrapping a hyphenated wrap results in a space, too. * Doesn't deal with orphan words at the end of a line, like 'I' in the paragraph above. * Doesn't know to put double spaces at the end of a sentence. I've turned off whitespace squeezing, so it leaves my double spaces alone, but if a sentence begins on a new line and it wraps it elsewhere, then the result has only one space between sentences. Particularly annoying if I run the wrapper multiple times. With two spaces, a word might be wrapped to the next line. Rewrap, and it says 'hm, I can fit that word on the line above' (but with a single space). But then if I add the space and rewrap again, it puts it on the line below again... This is configurable, but requires turning on sentence sensing and capitalisation mode, and I'm a little leery of giving it even more responsibility. :) I hope to factor this into my wrapping routine someday. * Sometimes mistakes short words at the start of a line with a period (or bracket) following as a lettered bullet, even if there are no other similar bullets around. * Doesn't like smileys too much. But if I format multiple paragraphs at once, it seems to recognise the smiley as irrelevant to the flow and handles it properly. * I particularly have to avoid running it on the more special- purpose parts of my e-mails, like code. This is why I map it to the equals sign ('equalprg' option). I press V, move around to highlight the lines I want, then press =. Double-edged sword? You bet. Best I've got so far, but I'm always looking for better.
Attachment:
signature.asc
Description: Digital signature