Skip to main content
edited tags
Link
muru
  • 25.1k
  • 8
  • 83
  • 144
Source Link
Sparhawk
  • 600
  • 1
  • 3
  • 18

How can I make vim's flowing aware of email replies?

#Problem summary I use vim to edit emails that I send with mutt. I also use format=flowed, which "reflows" text. That is, lines are limited to a fixed number of characters, and a "soft wrap" is applied, as indicated by the presence of a trailing space.

In vim, I have the following set:

setl tw=72
setl fo=aw

This sets the line length to 72 charaters, and sets up autoformatting with the trailing space. This works well in general. However, if I attempt to quote something with >, this character is not treated as a special character, and will be considered "inline" to the text.

#Example Copy the following text and paste it into vim.

Tempus. Vivamus. Dis natoque vitae erat. Consectetuer adipiscing nullam nec gravida non, at posuere enim, consectetuer ve. [1]

vim correctly breaks it into two lines, the first with a trailing space.

Tempus. Vivamus. Dis natoque vitae erat. Consectetuer adipiscing nullam 
nec gravida non, at posuere enim, consectetuer ve. [1]

I add > by selecting the lines and using :'<,'>s/^/> /, which results in the following.

> Tempus. Vivamus. Dis natoque vitae erat. Consectetuer adipiscing nullam 
> nec gravida non, at posuere enim, consectetuer ve. [1]

However, I now want to remove the [1] from the end, so I navigate to the end and delete. vim now reflows to the following, with the > "inline".

> Tempus. Vivamus. Dis natoque vitae erat. Consectetuer adipiscing 
nullam > nec gravida non, at posuere enim, consectetuer ve.

What's even worse is that I can delete the > manually and insert a new > before nullam, but this will immediately be reflowed to the previous line as follows.

> Tempus. Vivamus. Dis natoque vitae erat. Consectetuer adipiscing > 
nullam nec gravida non, at posuere enim, consectetuer ve.

#Question Is there a way to make vim's flowing aware of >? FWIW I've also tried this mail.vim customised for format=flowed, but it suffers from the same problems.