Vim line wrap with indent

gvimvim

Vim/gvim will wrap long lines like this:

000000000000000000000000000000000000|
00000000000000                      |
    11111111111111111111111111111111|
111111111111111111                  |
    22222222222222222222222222222222|
222222222222222222                  |
        3333333333333333333333333333|
3333333333333333333333              |

Is there a way to get Vim to display these lines wrapped like this instead?:

000000000000000000000000000000000000|
 00000000000000                     |
    11111111111111111111111111111111|
     111111111111111111             |
    22222222222222222222222222222222|
     222222222222222222             |
        3333333333333333333333333333|
         3333333333333333333333     |

I want the wrapped line to start a little past the indent of where that line started. (Just to be clear, I'm talking about wrap, i.e. soft line breaks, not textwidth.)

I want the indentation of the line to be considered in the wrapping of that line so that the code structure isn't hidden by wrapped lines.

Best Answer

UPDATE: This functionality landed in vim 7.4.338, though you'll want 7.4.354 or later.


So apparently this requires a patch to Vim. There is a patch by Vaclav Smilauer from back in 2007. I updated the patch to work with Vim 7.2.148 from Fedora 11. But it does seem to do the job.

Related Question