开发者

How to wrap the text 5 characters before the end of window?

开发者 https://www.devze.com 2022-12-23 02:58 出处:网络
I would like to wrap the text 5 characters before the end of window (without breaking the lin开发者_开发百科e).

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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号