这个功能已经在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
。
您还可以给出负数的shift值,这将使showbreak
字符和换行文本回到任何可用的缩进空间中。
在指定min
值时,如果终端宽度更窄,则移位量将被压缩,但showbreak
字符始终被保留。
:set autoindent
和:set smartindent
。 - Shammel Lee