" " copy_linebreak.vim: Bind user-defined key sequences to toggle a group of " options that make text wrapped with 'wrap' copy-paste friendly. Also creates " user commands if it can. " " Author: Tom Ryder " License: Same as Vim itself " if exists('g:loaded_copy_linebreak') || &compatible finish endif if !has('linebreak') finish endif let g: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? let &showbreak = s:showbreak_save unlet s:showbreak_save 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 CopyLinebreakEnable() else call CopyLinebreakDisable() endif endfunction " Provide mappings to the functions just defined noremap \ CopyLinebreakEnable \ :call CopyLinebreakEnable() noremap \ CopyLinebreakDisable \ :call CopyLinebreakDisable() noremap \ CopyLinebreakToggle \ :call CopyLinebreakToggle() " Provide user commands if we can if has('user_commands') command -nargs=0 \ CopyLinebreakEnable \ call CopyLinebreakEnable() command -nargs=0 \ CopyLinebreakDisable \ call CopyLinebreakDisable() command -nargs=0 \ CopyLinebreakToggle \ call CopyLinebreakToggle() endif