tags:

views:

1997

answers:

4
+7  Q: 

Word wrap in Gvim

How do I make Gvim word wrap in such a way that doesn't break words in the middle?

+1  A: 
:set tw=78

sets the text width to 78 characters. You can use "[movement]gq" to re-wrap some text.

Paul Tomblin
This is not exactly what I had in mind. If I resize the window it still breaks the words. I want the same behavior you would expect in Windows text editors.
Epsilon Vector
+1  A: 

You can

:set nowrap

to just let huge lines scroll of the edge of your screen. But tw is probably the better way to go.

ddvlad
:set wrap will then enable wrapping :-p
widgisoft
A: 

You can also use wrapmargin, which the manual defines as:

Number of characters from the right window border where wrapping
starts.  When typing text beyond this limit, an <EOL> will be inserted
and inserting continues on the next line.
Peter
I'm confused by this option: I don't want my current terminal width to determine how the file is saved.
Roger Pate
+9  A: 

Looks like there is a solution online after all.

:set formatoptions=l
:set lbr

Link: http://vim.wikia.com/wiki/Word_wrap_without_line_breaks

Epsilon Vector
Shouldn't that be `formatoptions+=l`?
Roger Pate
For anyone else having problems figuring out why linebreak/lbr won't work, double check that you haven't turned list on (i.e. :set nolist); it disables linebreak. (D'oh! Pulled out some hair while searching the docs because of that.)
Roger Pate