aboutsummaryrefslogtreecommitdiff
path: root/autoload/copy_linebreak.vim
blob: 3ea5f1c70ced46888037961e09a8cb3c52005675 (plain)
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
" Enable copy-friendly linebreak options
function! copy_linebreak#Enable() abort
  setlocal nolinebreak linebreak?
  let s:showbreak_save = &showbreak
  set showbreak=
  if exists('+breakindent')
    setlocal nobreakindent
  endif
endfunction

" Disable copy-friendly linebreak options
function! copy_linebreak#Disable() abort
  setlocal linebreak linebreak?
  if exists('s:showbreak_save')
    let &showbreak = s:showbreak_save
    unlet s:showbreak_save
  endif
  if exists('+breakindent')
    setlocal breakindent<
  endif
endfunction

" Toggle copy-friendly linebreak options, using the current setting for the
" 'linebreak' option as the pivot
function! copy_linebreak#Toggle() abort
  if &linebreak
    call copy_linebreak#Enable()
  else
    call copy_linebreak#Disable()
  endif
endfunction