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).
Maybe the linebreak
is the setting you're looking for?
:se linebreak
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.
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^