I have been wondering if Vim has the capability to smart wrap lines of code, so that it keeps the same indentation as the line that it is indenting. I have noticed it on some other text editor, such as e-text editor, and found that it helped me to comprehend what I'm looking at easier.
For example rather than
<p>
<a href="http://www.example.com">
This is a bogus link, used to demonstrate
an example
</a>
</p>
it would appear as
<p>
<a href="somelink">
This is a bogus link, used to demonstrate
an example
</a>
</p>
Best Answer
This feature has been implemented on June 25, 2014 as patch 7.4.338. There followed a few patches refining the feature, last one being 7.4.354, so that's the version you'll want.
Excerpts from vim help below:
Also relevant to this is the
showbreak
setting, this will suffix your shift amount with character(s) you specify.Example configuration
Note on behaviour
If you don't specify the
sbr
option, anyshowbreak
any characters put appended to the indentation. Removingsbr
from the above example causes an effective indent of 4 characters; with that setting, if you just want to useshowbreak
without additional indentation, specifyshift:0
.You can also give a negative shift, which would have the effect of dragging
showbreak
characters, and wrapped text, back into any available indent space.When specifying a
min
value, the shifted amount will be squashed if you terminal width is narrower, butshowbreak
characters are always preserved.