此功能已于2014 年 6 月 25 日作为补丁 7.4.338 实施。随后有几个补丁完善了该功能,最后一个是 7.4.354,所以这就是您想要的版本。
:help breakindent
:help breakindentopt
下面是 vim 帮助的摘录:
'breakindent' 'bri' boolean (default off)
local to window
{not in Vi}
{not available when compiled without the |+linebreak|
feature}
Every wrapped line will continue visually indented (same amount of
space as the beginning of that line), thus preserving horizontal blocks
of text.
'breakindentopt' 'briopt' string (default empty)
local to window
{not in Vi}
{not available when compiled without the |+linebreak|
feature}
Settings for 'breakindent'. It can consist of the following optional
items and must be seperated by a comma:
min:{n} Minimum text width that will be kept after
applying 'breakindent', even if the resulting
text should normally be narrower. This prevents
text indented almost to the right window border
occupying lot of vertical space when broken.
shift:{n} After applying 'breakindent', wrapped line
beginning will be shift by given number of
characters. It permits dynamic French paragraph
indentation (negative) or emphasizing the line
continuation (positive).
sbr Display the 'showbreak' value before applying the
additional indent.
The default value for min is 20 and shift is 0.
与此相关的还有showbreak
设置,这将在您指定的字符后缀您的班次量。
示例配置
" enable indentation
set breakindent
" ident by an additional 2 characters on wrapped lines, when line >= 40 characters, put 'showbreak' at start of line
set breakindentopt=shift:2,min:40,sbr
" append '>>' to indent
set showbreak=>>
行为注意事项
如果您不指定该sbr
选项,则任何showbreak
附加到缩进的字符。从上面的示例中删除sbr
会导致 4 个字符的有效缩进;使用该设置,如果您只想在showbreak
没有额外缩进的情况下使用,请指定shift:0
.
您还可以进行负移,这将具有将showbreak
字符和换行文本拖回任何可用缩进空间的效果。
指定min
值时,如果终端宽度较窄,移动量将被压缩,但showbreak
始终保留字符。