Reputation: 51147
I've noticed that gq does not work when I paste in a long line. For example, with a textwidth=72
and formatoptions=tcroqbnl
, gq refuses to wrap this (in insert mode, I pasted the entire label contents, and then exited insert mode with ESC):
<label for="contact_reason_1">To get assistance with or to confirm a tire replacement recommendation</label>
If I add a line break in (after "to", for example), it'll wrap then. The funny thing is if I join the line back together, it'll happily wrap it again. So VIM seems to somehow be remembering "oh, this is one paste, don't wrap it".
How do I turn that feature off? I'd like gq in command mode to always work. Taking l
out of formatoptions
did not seem to help (and it shouldn't, this isn't insert mode).
Yes, I'm using a motion command, in particular, gq<Right>. formatexpr
and formatprog
are both unset. If it matters, this is in gvim on Debian GNU/Linux, vim version 7.2p284.
This is a long line. A long line. But not wrappable yet. Or yet. Soon.
Now putting text in front of the long line.
note: there is a space after the final period, can't get SO to show it, except when this note is here. FUN.And some after.
note: space before the And, same SO problem.And some after.
; I can't get vim to wrap the rest of the line (without going into insert mode and doing a line break by hand, then it works).Fixing this state is doable; putting a newline after "now" and then hitting undo makes line wrap work again. WTF.
Upvotes: 6
Views: 7936
Reputation: 67760
I find that if I select the line before doing the gq, it works fine. Doesn't gq want to be combined with some text selection operation to work?
UPDATE
I confirm the bug. Running vim -u NONE, my formatoptions
are vt
.
Maybe Bram Molenar or at least the vim community would be interested?
Upvotes: 1
Reputation: 42667
gq isn't enough to wrap the text. You have to give it a motion over which to wrap (like gqj) or tell it to wrap the current line with gqq. Are you sure you're not just mistyping it?
If you aren't, what are the formatexpr
and formatprg
options set to, if anything?
Update
The problem is the b setting in formatoptions
. That's telling Vim to only wrap the text added during the last insertion.
Upvotes: 9