aboutsummaryrefslogtreecommitdiff
path: root/vim/config/linebreak.vim
blob: 887d5f398f79f9a3a05f96b98e88a136d1f8d565 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
" Break lines at word boundaries if possible and not simply at the last
" character that will fit on the screen, preceding the next line with three
" periods to make it obvious that it's a continuation of the previous line
if has('linebreak')
  set linebreak
  set showbreak=...
  if v:version > 704 || v:version == 704 && has('patch338')
    set breakindent
  endif

  " Bind \b to turn off linebreak and toggle the showbreak characters on and
  " off for convenience of copypasting multiple lines from terminal emulators.
  if has('eval')
    function! ToggleBreak()
      if &linebreak
        set nolinebreak
        set showbreak=
        if v:version > 704 || v:version == 704 && has('patch338')
          set nobreakindent
        endif
      else
        set linebreak
        set showbreak=...
        if v:version > 704 || v:version == 704 && has('patch338')
          set breakindent
        endif
      endif
    endfunction
    nnoremap <silent> <leader>b :<C-U>call ToggleBreak()<CR>
  endif
endif