diff options
| author | Chris Toomey | 2014-02-17 14:19:34 -0500 | 
|---|---|---|
| committer | Chris Toomey | 2014-02-17 14:19:34 -0500 | 
| commit | 37e585fc59f174706817ebf2e821c5080716cf24 (patch) | |
| tree | b4f28ebe9e1392237813ee6299ba4ecda408405f | |
| parent | 8527874d26d1a1f94bd81df686b65f1af5673dae (diff) | |
| download | vim-system-copy-37e585fc59f174706817ebf2e821c5080716cf24.tar.bz2 | |
All but single line working
| -rw-r--r-- | plugin/system_copy.vim | 20 | 
1 files changed, 14 insertions, 6 deletions
| diff --git a/plugin/system_copy.vim b/plugin/system_copy.vim index f9ebba6..98b7d0b 100644 --- a/plugin/system_copy.vim +++ b/plugin/system_copy.vim @@ -10,17 +10,25 @@ let g:loaded_system_copy = 1  function! s:system_copy(type, ...) abort    let mode = <SID>resolve_mode(a:type, a:0) -  echohl String | echon 'Activated from: ' . mode | echohl None +  if mode == s:linewise +    let first = line("'[") +    let last = line("']") +    let to_copy = join(getline(first, last), '
') +  elseif mode == s:visual || mode == s:blockwise +    silent exe "normal! `<" . a:type . "`>y" +    let to_copy = getreg('@') +  else +    silent exe "normal! `[v`]y" +    let to_copy = getreg('@') +  endif +  silent call system('pbcopy', to_copy) +  echohl String | echon 'Copied to system clipboard via: ' . mode | echohl None  endfunction  function! s:resolve_mode(type, arg)    let visual_mode = a:arg != 0    if visual_mode -    if a:type == '' -      return s:blockwise -    else -      return s:visual -    end +    return (a:type == '') ?  s:blockwise : s:visual    elseif a:type == 'line'      return s:linewise    else | 
