When writing email messages I use the following settings:

:set wrap
:set textwidth=72

Say, I do the following:

1. I enter insert mode

2. I start to type the following introductory text:

   I am writing this short email message to ask the friendly and
   highly competent folks at vim@vim.org for some help regarding 
   the text wrapping feature of Vim... As I was writing an email
   message last night, I ran in to the following problem:

3. So I start typing:

   I am writing this short email message to ask the friendly folks at
   vim@vim.org for some help regarding the text wrapping feature

4. I realize at this point that I left out the "highly competent" bit
   so I escape back to normal mode and move the cursor back to the "f"
   of "folks", hit 'i' to switch back to insert mode, type the missing
   text and obtain the following:

   I am writing this short email message to ask the friendly and highly
   competent folks at
   vim@vim.org for some help regarding the text wrapping feature

5. The first line was correctly "re-wrapped" to accommodate the
   additional text, with "competent folks at" moved to the second line 
   but now the rest of my original entry has been moved to a third line 
   (vim@vim.org for some help .. etc.)

6. At this point I escape back to normal mode and hit 'J' to join line
   2-3 and obtain the following:

   I am writing this short email message to ask the friendly and highly
   competent folks at vim@vim.org for some help regarding the text wrapping 
feature

7. So I hit 'A' to append the rest of my text to line 2:

   I am writing this short email message to ask the friendly and highly
   competent folks at vim@vim.org for some help regarding the text wrapping 
feature of Vim... As I was writing an email message last night I ran into the 
following problem:

8. In other words and in case the last line above is either truncated or
   rewrapped on your mail reader.. once you have decided to join two
   lines into one long (> textwidth) line, vim quite logically lets you
   append as much text as you wish to that line. 

9. So far the way I handle this is that after J-oining my two lines as
   described above, I move the cursor to the first space before col.72, hit
   'i' and manually insert a carriage return to move the excess text to
   the following line:

   I am writing this short email message to ask the friendly and highly
   competent folks at vim@vim.org for some help regarding the text 
   wrapping feature

Now, after doing the above a number of times I began to think there must
be a better way to handle this type of situation:

1. When I end up with (4) above, is there a better strategy than using
   'J' to join line #2 and line #3 .. something that would take me
   directly from (4) to (9) .. hit 'A' and since the cursor would now
   be to the left of col. 72, continue entering my text and benefit 
   from the wrap feature automatically?

2. More generally, is there a command - or sequence of commands - that 
   would let me reformat a paragraph to take care of any line that goes
   beyond the limit set via the textwidth option?

Thanks,

cga

Reply via email to