Wrap the long lines in Wim?

I noticed that gq does not work when I insert a long string. For example, with textwidth=72 and formatoptions=tcroqbnl , formatoptions=tcroqbnl refuses formatoptions=tcroqbnl this (in insert mode, I inserted the entire contents of the label, and then exited insert mode using ESC ):

 <label for="contact_reason_1">To get assistance with or to confirm a tire replacement recommendation</label> 

If I add a line break (for example, after the "to"), it will be wrapped. The funny thing is that if I join the line again, she will gladly wrap it again. So VIM, it seems, somehow recalls: "Oh, this is one paste, do not wrap it."

How to disable this feature? I would like gq to always work in command mode. formatoptions l of formatoptions did not seem to help (and should not, this is not insert mode).




lightening

Yes, I use a motion command, specifically gq <Right> . formatexpr and formatprog both not installed. If that matters, it is in gvim for Debian GNU / Linux, vim version 7.2p284.

Playback Actions

  1. Call gvim in an open file.
  2. Press i to enter insert mode, then enter This is a long line. A long line. But not wrappable yet. Or yet. Soon. This is a long line. A long line. But not wrappable yet. Or yet. Soon. This is a long line. A long line. But not wrappable yet. Or yet. Soon.
  3. Press ESC , then I. Enter Now putting text in front of the long line. note: there is a space after the last period, so it cannot display it, except when this note is here. FUN.
  4. Press ESC , then A. Like And some after. note: space before A, same problem SO.
  5. Press ESC one last time. Now try gq <Left> , note that only wraps And some after. ; I can't get vim to wrap the rest of the line (without going into insert mode and without doing a line break manually, then this works).

Correction of this condition is doable; adding a new line after β€œnow”, and then clicking the β€œCancel” button again leads to line breaks. WTF.

+3
vim paste wrap word-wrap
Dec 09 '09 at 13:50
source share
2 answers

g q is not enough to wrap the text. You must give it a movement that you can wrap around (for example, g q j ), or tell him to wrap the current line with g q q . Are you sure you’re not just fooling him?

If you do not know what formatexpr and formatprg set, if anything?

Update
The problem is setting b to formatoptions . This tells Vim to only wrap the text added during the last insertion.

+7
Dec 09 '09 at 13:59
source share

I find that if I select a line before executing gq, it works fine. Does gq want to be combined with some text selection operation?

UPDATE

I acknowledge the error. Running vim -u NONE, my formatoptions vt .

Maybe Bram Molenar, or at least the vim community would be interesting?

+1
Dec 09 '09 at 14:02
source share



All Articles