sponsor Vim development Vim logo Vim Book Ad

breakindent_beta.vim : Improves indentation of wrapped lines by updating showbreak for current line.

 script karma  Rating 17/7, Downloaded by 2183  Comments, bugs, improvements  Vim wiki

created by
joey twiddle
 
script type
utility
 
description
BreakIndent Beta tries to make wrapped lines look neater and less disruptive, by updating showbreak to indent them to the same column as the currently focused line.

Warning: Because it changes showbreak, it can cause lines to visibly shift up and down when a new indent is applied.  To reduce how often this happens, you can enable breakindent_update_rarely, breakindent_match_gap or breakindent_never_shrink.

BreakIndent Beta is a pure vimscript alternative to the old breakindent patch, which I failed to get working smoothly in modern Vim.  Unlike the breakindent patch, this vimscript *cannot* present a different indent for each line.  Instead it updates the showbreak option to fit the indent of the current cursor line.  Unfortunately this means that showbreak can change often, and other lines on the display may not appear at the ideal indent.

Some commands that may be useful when wrapping long lines:

   :set wrap                  " This script does nothing in nowrap mode
   :set linebreak nolist      " Break lines cleanly at word gaps, hides tabs
   :set list                  " Visible tabs, breaks words anywhere

   :set textwidth=0
   :set wrapmargin=0          " Attempts to disable auto-linefeed when typing
   :set formatopts-=cq

   :highlight NonText ctermfg=darkblue     " Theme your indent symbols
   :let g:breakindent_match_gap = 1        " Change breakindent settings
 
install details
Drop the script in your plugin folder, or just source it when you need it.

See the source code for options, all of which can be changed at runtime through global vars.
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
breakindent_beta.vim 1.6 2012-10-24 6.0 joey twiddle Latest stable well-documented version.
breakindent_beta.vim 1.2 2012-10-24 7.0 joey twiddle Added support for breakindent_match_gap
breakindent_beta.vim 1.1 2012-10-24 6.0 joey twiddle Initial upload
ip used for rating: 142.132.191.50

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github