I would like to wrap the text 5 characters before the end of window (without breaking the lin开发者_开发百科e).
I don't know how to do this without putting an EOL character in the text (wrapmargin/textwidth).
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^
Maybe the linebreak
is the setting you're looking for?
:se linebreak
精彩评论