aboutsummaryrefslogtreecommitdiff
path: root/vim/plugin/copy_linebreak.vim
blob: 1dc537d46ae0de63878a1ea6749d4651ce86e9ba (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
32
33
34
35
36
"
" Bind a user-defined key sequence to turn off linebreak and toggle the
" showbreak characters and breakindent mode on and off, for convenience of
" copying multiple lines from terminal emulators.
"
" Author: Tom Ryder <tom@sanctum.geek.nz>
" License: Same as Vim itself
"
if has('eval')

  " Define function
  function! s:CopyLinebreak()

    " If linebreak is on, turn it off
    if &l:linebreak
      setlocal nolinebreak linebreak?
      setlocal showbreak=
      if exists('&breakindent')
        setlocal nobreakindent
      endif

    " If it's off, turn it on
    else
      setlocal linebreak linebreak?
      setlocal showbreak<
      if exists('&breakindent')
        setlocal breakindent
      endif
    endif

  endfunction

  " Provide mapping proxy to the function just defined
  noremap <Plug>CopyLinebreak
        \ :<C-U>call <SID>CopyLinebreak()<CR>
endif