Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So I have the following set in my vim:

set wrap linebreak textwidth=78

which wraps the line when you type more than 78 characters, HOWEVER! if you try and make a change in the middle of the line, this feature does not see to work anymore, the line does not softwrap properly, thus more than 78 character are placed in the line....

So I was wondering.. what do you do?

share|improve this question
up vote 3 down vote accepted

You are confusing the concepts of wrapping and formatting, as those concepts are used by Vim. Wrapping refers to the display of lines whose length exceeds the screen width. Formatting refers to the breaking and joining of lines by the insertion and deletion of newlines, usually so that all the lines are 'textwidth' or less in length.

The 'wrap' and 'linebreak' options affect how long lines are displayed. They do not affect the content of the lines. They affect how lines are wrapped at the right edge of the screen; their behavior is not affected by 'textwidth'.

The 'textwidth' option affects the point at which a line is broken by the addition of a newline as text is added to the line. This behavior is also affected by the 'wrapmargin' and 'formatoptions' options. The details of this behavior are discussed here:

:help 'formatoptions'
:help fo-table
:help 25.1

Vim has an auto-formatting capability that you might find useful. See

:help auto-format

It's too intrusive for my taste. I prefer to keep all my text within a textwidth of 78 for code and 68 for e-mail. Vim automatically adds a newline and puts the cursor on the next line when I append to a line and the length exceeds 'textwidth'. As I edit in the middle of lines the formatting becomes ugly, but I just wait until I have finished with that paragraph or comment, then reformat the whole thing with some variation of the gq command.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .