After reading help textwith and help fo-table, I expected that when I set

set textwidth=20  " for demonstration
set formatoptions=tcq

then inserting text would always eventually cause a line to wrap, but that isn't the case. Wrapping only happens at (or before) my cursor. And if I paste, wrapping doesn't happen at all.

Example (Vim 7.4):

This is a long line

The line will auto-wrap if I hit A and start typing.

But if I hit 02wi and type "still ", it doesn't wrap:

This is still a long line

I have to type another 7 characters before it will wrap, and then the problem continues on the next line:

This is still more <-- it wraps here
typing and again a long line

Pasting doesn't trigger a wrap either:

This is a long line This text is pasted and not wrapped

I think what I want is set fo+=a but that applies at the paragraph level, whereas I don't want auto-formatting of one line to spread to other lines.

Or am I missing an option?

To be clear, after launching vim -u NONE, this is what I type (less comments):

:set textwidth=20<CR>
:set formatoptions=tcq<CR>
iThis is a long line<ESC>
02wistill <ESC>                " no wrap happens, but I'd like it to
:let @r = "This text is pasted and not wrapped"<CR>
$"rp                           " no wrap happens, but I'd like it to
  • 1
    This seems to work fine for me. I started Vim with vim -u NONE to prevent loading a vimrc file. Does this fix the problem for you? Which Vim version are you using? Jun 23, 2015 at 22:28
  • No, that doesn't help. Vim 7.4 on Windows and Ubuntu.
    – mgiuffrida
    Jun 24, 2015 at 5:32
  • Is paste set, accidentally? Try:set paste? Jun 24, 2015 at 15:40
  • @VolkerSiegel no, paste is not set. When paste is set no wrapping happens at all.
    – mgiuffrida
    Jun 24, 2015 at 19:48

1 Answer 1


I came across a partial solution, using formatoptions=tcqaw. Basically, you still auto-wrap paragraphs, but a paragraph ends when the line has no trailing whitespace, which is suitable for many cases.

Using your example (with a slight modification, no undo and using "<SPACE>This...") I get this result:

This is still a long  
This is pasted and 
not wrapped

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.