此功能已作为补丁 7.4.338 提供 implemented on June 25, 2014。随后有几个补丁完善了该功能,最后一个是 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 字符。