diff options
Diffstat (limited to 'vim/plugin/copy_linebreak.vim')
-rw-r--r-- | vim/plugin/copy_linebreak.vim | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/vim/plugin/copy_linebreak.vim b/vim/plugin/copy_linebreak.vim new file mode 100644 index 00000000..1dc537d4 --- /dev/null +++ b/vim/plugin/copy_linebreak.vim @@ -0,0 +1,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 |