You can set the text width using
:set textwidth=n (or
:set tw=n) where n is a positive integer, for example:
That will automatically wrap text as close to 79 characters as white space allows without exceeding the 79 character limit. This option wraps at word boundaries.
The textwidth option can be unset using:
If you want to apply this to specific areas; bring the cursor at the beginning of the text you want to format and type
gq. Now specify the range, say
$ to format a large line.
sets a wrap margin of 2 characters from the right window border. A system-dependent EOL character is inserted and the line wraps as you type. This option may be useful in some situations, but probably is not what you are looking for.