vim line wrap with indent
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.
In your .vimrc:
set wrap " soft-wrap lines
" requires +linebreak compile-time option (not in the 'tiny' and 'small' builds); check your :version
set showbreak=-----> " prefix for soft-wrapped lines (no actual line break character)
"set linebreak " soft-wrap lines only at certain characters (see :help breakat)
" If you like line numbers, you may want this instead:
"set number
"set showbreak=------>\ " line up soft-wrap prefix with the line numbers
"set cpoptions+=n " start soft-wrap lines (and any prefix) in the line-number area
Or just type :set showbreak=----->
in any session.
For reference, my research trail (Vim 6.2): :help 'wrap'
-> :help 'linebreak'
-> ( :help 'showbreak'
-> :help 'cpoptions'
, :help 'breakat'
)
The solution to your question can be achieved setting two parameters in your vimrc
:
To break the lines with the same indentation:
set breakindent
And one space for indenting soft-wrapped lines:
let &showbreak=' '
It will work this way:
111111111111111|
11111111111111|
11111 |
222222222222222|
222222222222 |
333333333333333|
33333 |