diff options
Diffstat (limited to 'plugin/copy_linebreak.vim')
-rw-r--r-- | plugin/copy_linebreak.vim | 49 |
1 files changed, 7 insertions, 42 deletions
diff --git a/plugin/copy_linebreak.vim b/plugin/copy_linebreak.vim index 8b93c24..76d9228 100644 --- a/plugin/copy_linebreak.vim +++ b/plugin/copy_linebreak.vim @@ -5,53 +5,18 @@ " Author: Tom Ryder <tom@sanctum.geek.nz> " License: Same as Vim itself " -if exists('loaded_copy_linebreak') || &compatible - finish -endif -if !has('linebreak') || v:version < 600 +if exists('loaded_copy_linebreak') || &compatible || v:version < 700 finish endif let loaded_copy_linebreak = 1 -" Enable copy-friendly linebreak options -function! s:CopyLinebreakEnable() - setlocal nolinebreak linebreak? - let s:showbreak_save = &showbreak - set showbreak= - if exists('+breakindent') - setlocal nobreakindent - endif -endfunction - -" Disable copy-friendly linebreak options -function! s:CopyLinebreakDisable() - 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! s:CopyLinebreakToggle() - if &linebreak - call s:CopyLinebreakEnable() - else - call s:CopyLinebreakDisable() - endif -endfunction - " Provide mappings to the functions just defined -noremap <silent> +nnoremap <silent> <unique> \ <Plug>(CopyLinebreakEnable) - \ :<C-U>call <SID>CopyLinebreakEnable()<CR> -noremap <silent> + \ :<C-U>call copy_linebreak#Enable()<CR> +nnoremap <silent> <unique> \ <Plug>(CopyLinebreakDisable) - \ :<C-U>call <SID>CopyLinebreakDisable()<CR> -noremap <silent> + \ :<C-U>call copy_linebreak#Disable()<CR> +nnoremap <silent> <unique> \ <Plug>(CopyLinebreakToggle) - \ :<C-U>call <SID>CopyLinebreakToggle()<CR> + \ :<C-U>call copy_linebreak#Toggle()<CR> |