tags:

views:

97

answers:

4
+1  Q: 

vim: wrap question

I would like to wrap the text 5 characters before the end of window (without breaking the line). I don't know how to do this without putting an EOL character in the text (wrapmargin/textwidth).

A: 

Maybe the linebreak is the setting you're looking for?

:se linebreak
soulmerge
That paired with the `'wrap'` option will perform visual wrapping of lines at word boundaries. There isn't a way to specify exactly how far from the edge of the window the wrapping will occur.
jamessan
@jamessan: That is absolutely correct. But it looks to me like the OP is trying get a better visual overview of wrapping text, where I though that this option might help.
soulmerge
A: 

Linebreak is active.

I would like to wrap the text 5 characters before the window border (5 characters before linebreak) but without putting an EOL character.

remio
You can't do that. The only control you have over how visual wrapping is done are the `'linebreak'` and `'breakat'` options and those simply determine whether the line will be wrapped at the last character in the window or the character in `'breakat'` that's closest to the edge of the window.
jamessan
A: 

Soulmerge,

What is OP?

remio
*You* are. The Original Poster.
Johnsyweb
A: 

You need to set 3 options as follows:

:set linebreak
:set wrap
:set nolist

If any of these are set otherwise (e.g. :set list), then it won't work.

Additionally, there is an option to set a character which will display at the beginning of wrapped lines. e.g.:

:set showbreak=>

If you want to turn that feature off again, set it to an empty string:

:set showbreak=

Note that even though wrapped lines look like lines in their own right, Vim still considers them to be a single line. So moving the cursor down with the j key will move it on to the next numbered line, rather than the next displayed line. This makes better sense if you have line numbers displayed (:set number). If you want to move up and down through display lines, you can use gk and gj instead. Here are a few more g commands that you will find useful:

Numbered line           Display line
-------------           ------------
j                       gj
k                       gk
$                       g$
0                       g0
^                       g^
nelstrom